Support » Fixing WordPress » Recent posts in sidebar display current post's thumbnail

Viewing 10 replies - 1 through 10 (of 10 total)
  • Michael


    Forum Moderator

    try and change this section:
    <?php the_post_thumbnail ($_post->thumbnail, 'popular'); ?>

    <?php echo get_the_post_thumbnail ($_post->ID, 'popular'); ?>

    (not sure if ‘popular’ refers to a thumbnail size?)

    Pure awesomeness!! That did the trick indeed. Thank you for your help and for responding so quickly. BTW, you are right, “popular” is a thumbnail size.

    Happy Sunday,

    Where is this “popular” defined?

    Actually, would you also mind uploading your CSS that applies to this? Your site looks very crisp and clean, I love it.

    Hi Derek,

    Hmm, it’s been a while and can’t remember all the details, I’m sorry. I think “popular” was not a thumbnail size after all, but rather a parameter used in the code to query the images from the respective posts.

    What formats the actual thumbnails is a class defined as “th” in the CSS stylesheet as follows:

    .th {
    	display: block;
    	margin: 0 0 .5em;
    .th.fl img {
    	margin-right: 10px;
    .th.fl img
    	border: 1px solid #cfcfcf;

    The text that accompanies the thumbnails (which would be the title of the posts) simply inherits the properties you define in the stylesheet for the sidebar text widgets, which is what I used.

    Does this help?

    Hi, thanks for the reply. This is great. I just need to figure out the “popular” part, as it does not seem to work for me. there must be some declaration that I need to do for it.

    Ok, correction, while I’m not sure what popular does, this does work. However, it is calling the full sized image and then generating its own thumbnail, which can cause a considerable lag as they download, depending on the size of the original. I’m going to toy with this, but if you, or any other reader, happens to know how to augment the code above to call the thumbnail only, I’d love to hear how.


    Okay, got it figured out, sorry for the flurry of updates. I used this code:

    <?php foreach ( (array) get_posts('numberposts=5') as $_post ) : ?>
    <div class="th fl"><?php echo get_the_post_thumbnail ($_post->ID, 'thumbnail'); ?>
    <div><?php echo $_post->post_title; ?></div>
    <div class="hl2"></div>
    <?php endforeach; ?>

    Note I’ve replaced ‘popular’ with ‘thumbnail’ and now true thumbnails are put in place, which default at 150×150. The 40×40 is generated using your CSS above.

    Thanks again,

    Great! The code I used is a carry over from older designs I’ve used over the years before WordPress supported automatic thumbnails, featured images, etc. out of the box. In other words, it’s pretty old.

    Thank you for bringing it up to date and making it better!


    Thank you again! Very helpful! Derek

    PS: You site is quite elegant and nice, great job!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Recent posts in sidebar display current post's thumbnail’ is closed to new replies.