WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Featured post thumbnail in sidebar

[Resolved] Featured post thumbnail in sidebar

  • For whatever reason, when I place the below featured image code in the sidebar, the image displayed is not the featured image of the present post, though it is an image from another post in the same category.

    <?php the_post_thumbnail( '280x280' ); ?>

    I have disabled caching plugin and have cleared cache and cookies. Any suggestions?

    -Scott

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

    @alchymyth

    Forum Moderator

    outside the loop, it is not predictable which thumbnail gets shown; this might depend on secondary codes in your site.
    http://codex.wordpress.org/Function_Reference/the_post_thumbnail

    if you can get the post ID of the current post, you could try using

    <?php $post_id = ?????; echo get_the_post_thumbnail($post_id,'280x280'); ?>

    http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    Check out the default thumbnails sizes

    Try to declare the post as a variable.

    <?php
    global $post;
    if( $post && has_post_thumbnail( $post->ID ) ) {
        get_the_post_thumbnail( $post->ID,'mediuum' );
    }
    ?>

    If you have not changed the Medium thumbnail in the settings then.

    <?php
    global $post;
    if( $post && has_post_thumbnail( $post->ID ) ) {
        get_the_post_thumbnail( $post->ID,array(280,280) );
    }
    ?>

    HTH

    David

    Thanks @atchymyth and David, I’ll give each a try and report back.

    @atchymyth- I couldn’t figured how to get the current post, so that code didn’t work for me

    David- neither code worked for me

    I was able to show it using the following code…

    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
      the_post_thumbnail( array(250,250));
    }
    ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Featured post thumbnail in sidebar’ is closed to new replies.
Skip to toolbar