WordPress.org

Support

Support » Plugins and Hacks » Using the Post Thumbnail Feature with WordPress Popular Posts

Using the Post Thumbnail Feature with WordPress Popular Posts

  • By default, WordPress Popular Posts will attempt to generate a thumbnail from the first image attached to your posts. However, you can also select a custom thumbnail by enabling The Post Thumbnail functionality on your blog. To do this, simply add this line of code to your theme’s functions.php file:

    // Enable post thumbnails
    add_theme_support(‘post-thumbnails’);

    Once you’re done with that, go to your WordPress Admin interface and you should see a nex bow called Post Thumbnail (renamed “Featured Image” on WordPress 3.0) under the Add New Post / Edit Post screens. Pick the image of your choice, click on Use as thumbnail (changed to “Use as featured image” on WordPress 3.0) and save changes.

    Now WordPress Popular Posts will use your selected images as thumbnails!

Viewing 15 replies - 1 through 15 (of 23 total)
  • Please note that this tutorial applies only for WordPress Popular Posts v2.1.0 and newer. Earlier versions don’t support this feature.

    Thank you for new version plugin, work fine for me especially widget area.

    But how I can use this features at shortcode or template tag, manually generated using specified parameter.

    Thank You.

    I fixed the problem. All work fine.

    problem is my browser cache. I tried clear cache [CTRL] + [R]

    Thank you.

    Good to know that, mansur!

    Thanks for the information, but what about when you’re using the PHP code and not the widget?

    eg:

    <?php if (function_exists(‘wpp_get_mostpopular’)) wpp_get_mostpopular(“range=weekly&order_by=comments”); ?>

    Cheers!

    Hi mat2t,

    It also applies to the PHP code. Here’s an example:

    <?php
    if (function_exists('wpp_get_mostpopular')) wpp_get_mostpopular("range=weekly&order_by=comments&thumbnail_selection=usergenerated");
    ?>

    You can find more about this attribute and others on your wp-admin > Settings > WordPress Popular Posts page.

    Thanks a lot for your help Ikki24.

    I used your exact code in my sidebar, but I’m not seeing the thumbnails.

    It shows the title and number of comments, but not thumbnail.

    I have set a thumbnail (featured image in WP 3.0)

    I also checked the source, no sign of any images :/

    Thanks again.

    Sorry ma2t, forgot to mention that you also need to specify the width & height of the thumbnails, like so:

    <?php
    if (function_exists('wpp_get_mostpopular')) wpp_get_mostpopular("range=weekly&order_by=comments&thumbnail_selection=usergenerated&thumbnail_width=30&thumbnail_height=30");
    ?>

    That should work.

    Ah cool thanks Ikki24 🙂

    But unfortunately that’s what I was trying to avoid…

    With the built in wordpress featured image, you can set it to not crop exactly. Mine is set to 50 px wide, and whatever high (bigger number). I always use landscape images so it’s okay, but the height will vary a little each time

    Using the wordpress <?php the_post_thumbnail(); ?> code, it brings it in at the correct size. Without needing to specify a size.

    Having to specify a size will result in slightly squashed or stretched images.

    Oh well. Thanks for the help!

    Cool!

    Not sure if the latest update fixed this or not, but it seems to be working well now 🙂

    I used the code you gave me, but changed the width to 50, and height to 35, now even if my thumbnail is less than 35 in height, it still displays it correctly (values from WP), no stretching or squashing!

    Great news, thanks for the help.

    Nope, haven’t changed anything ma2t! ( at least, nothing related to the thumbnail feature anyways 😛 )

    If you set the thumbnail_source parameter to usergenerated (like the example code I posted above), then WPP will use the get_the_post_thumbnail() function and should handle everything (such as image cropping and rezising).

    I am, however, thinking of removing either the attribute width or height from the HTML that my plugin echoes to screen to avoid the image stretching effect.

    Oh! Well, as long as it’s working 🙂

    Yeah, I feel it would be a good idea to allow the thumbnail (featured image) to show if just “thumbnail_selection=usergenerated” was used, and no need for the width or height.

    As I think these values can come from the wordpress code.

    Thanks for the great work!

    Hi, just wondering whether the generate thumbnails bit works with Multisite, as I’ve read that wpmu in the past had problems with timthumb script, it wouldn’t work by default. So far I’ve played around with it and it hasn’t been generating the thumbnails. I made the cache directory writeable btw.

    Hi patung,

    To be perfectly honest with you, I had no idea my plugin even worked on MU till recently when someone told me it did.

    Anyways, back on topic. If you set WordPress Popular Posts to generate all the thumbnails for you, it’ll use timthumb.php to do so. I’ve heard that MU has some issues with timthumb.php but again as I said before I had no idea people were using my plugin on MU blogs so I really didn’t worry about that since I was developing thinking of standalone WordPress blogs and not MU. Can’t tell how to fix this for MU blogs as I don’t really know how MU works.

    On the other hand, if you set WPP to use the thumbnails you’ve selected under Featured Image then my plugin will use this instead and should be able to display a thumbnail. The timthumb.php script won’t be used at all. You might want to try this approach instead, theoretically speaking it should work.

    Thanks Ikki, yes that’s what I did, incidentally this is the post that people always bring up when wpmu and timthumb are discussed – http://www.binarymoon.co.uk/2009/10/timthumb-wordpress-mu/

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Using the Post Thumbnail Feature with WordPress Popular Posts’ is closed to new replies.