• Alright this is driving me nuts. I’d like to assign a different thumbnail image to each of my posts with a custom field, and then have a “recent posts” section in my sidebar that pulls up that image and the title of the post. Does anyone know how to do that, or can point me in the right direction?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Jess

    (@jessn)

    In case it helps anyone I figured how to make it work. I found a couple of plugins that did sort of what I needed and combined parts of each. Here’s what I came up with and it works great:

    <?php $myposts = get_posts('numberposts=5&offset=0');
    foreach($myposts as $post) :?>
    <?php $thumbnail = get_post_meta($post->ID, 'post_thumbnail', true); ?> 
    
    <ul>
    <li><a href="<?php the_permalink(); ?>"><?php the_title();?>
    <img src="<?php echo $thumbnail; ?>" alt="<?php the_title(); ?>" />
    </a></li>
    </ul>
    <?php endforeach; ?>

    jessn,
    could you link to your site so that we may see the result?
    I’ve been trying to find a solution to that problem for days.

    yeaaa … give us a link i`m searching for the same thing

    bandwidthfilms

    (@bandwidthfilms)

    How do I add an if.. and code to this, so that if my post doesn’t have a thumbnail, i’ll see a default image??

    example:

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Recent posts in sidebar as thumbnails’ is closed to new replies.