Support » Alpha/Beta/RC » Use more than one Post Thumbnail in WP 2.9

  • Wondering if anyone knows (or if it’s even possible) to use more than one Post Thumbnail in WP 2.9.

    I have my functions.php set up as:

    <?php if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 100, 35, true ); // Normal post thumbnails
    	add_image_size( 'single-post-thumbnail', 400, 9999 ); // Permalink thumbnail size
    }?>

    And call my image (on my homepage) I set when writing a post as:
    <?php the_post_thumbnail(); ?>

    Is there a way to add more than one Post Thumbnail when writing a post and have it displayed?

    Thanks! :]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    I don’t think so, but what are you trying to accomplish? There may be a better way around that.

    I wanted to use this to place additional photos of a post on the homepage along side the main image being displayed for each post.

    Ultimately, I could do it with custom fields but I like the ease of the feature of the new Thumbnail option.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    That’s probably going to be the best way about it, unless you make a plugin. Which is how Post Thumbnails started in the first place 😉

    You don’t need a plugin, you can use wp_get_attachment_image or wp_get_attachment_image_src to retrieve the post attached images.

    @vteixeira: Woah, I didn’t know wp had that built in. Do I need to include anything in functions.php to use that?

    After looking into this a bit more…this is what I did. Not sure if it’s right or wrong, but it seems to work.

    In functions.php:

    <?php $args = array(
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'post_parent' => $post->ID
    );
    $images = get_posts( $args );
    foreach($images as $image):
    endforeach;
    ?>

    Inside the loop:
    <?php echo wp_get_attachment_image($images[0]->ID, 'thumbnail'); ?>

    Using [0],[1]…etc to set the number of images I wanted.

    Thoughts?

    ^^above actually displays the same images for every single post instead of using images per each post. Anyway to fix that?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Use more than one Post Thumbnail in WP 2.9’ is closed to new replies.