Support » How-To and Troubleshooting » post_thumbnail in post?

post_thumbnail in post?

  • Hi all

    I’m still new to WP and I’m having problems displaying the featured image of posts.

    I have added theme support for post thumbnails in functions.php

      set_post_thumbnail_size( 50, 50, true );

    I have added images as the featured image to posts.

    I have home.php as the Template page for a home page where I would like to display the post_thumbnail but the thumbnails don’t display and the else echos ‘no thumbs’ is output.

    Is there anything obvious from the page why this isn’t working or something else I need to do.

    Thanks in advance for any help.

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Why is the closing after the content?



    sorry I didn’t know about the forum number of lines of code rule
    here is the code


    Digital Raindrops – I don’t undertand, why is what closing after the content?



    Forum Moderator

    David is referring to the closing tag </a> for the link after ‘the_content()’ – having the link wrap the whole content is quite a stretch and can lead to problems and invalid code.

    there is no obvious reason in your code why a ‘featured image’ whould not get shown in the loop.

    are you sure you have a ‘featured image’ assigned to the post(s)?


    I have removed the tag so it doesnt wrap but I still dont have the thumbs.

    Im sure I have the featured images assigned in the posts. In the post I have the Featured Image on the right and inside it I have the image.




    Forum Moderator

    just double checking:
    do you have a ‘featured image’ assigned to the post(s) in the dashboard – posts – edit post page, as in the attached screenshot?

    also, review http://codex.wordpress.org/Post_Thumbnails

    whatever images are within the post content does not matter.

    Yes I have a ‘featured image’ assigned to the post(s) in the dashboard.


    I have read http://codex.wordpress.org/Post_Thumbnails but I can’t see anything there that I haven’t done.

    I think it might be time to give up.



    Forum Moderator

    what happens if you remove the conditional code:

    change this section:

                if ( has_post_thumbnail() ) {
                  echo 'no thumbs';


    <?php  the_post_thumbnail(); ?>

    – occasionally, a plugin interferes with some code;

    try to deactivate all plugins to see if that solves the problem; then re-activate one at a time to find the problem one.

    Removing the conditional and using

    <?php the_post_thumbnail(); ?>

    doesn’t do anything. I was using the conditional statement to try and debug the problem.

    I’m only using NextGen gallery at the moment, I turned that off but still no luck.

    I have tested this, it is a Page template” so only can be used on a page:
    Copied your code from pastebin
    Created a file and saved it in a themes folder
    Run WordPress, went to a page,
    Set the featured image, and the template page as “Home” saved and viewed the page.

    The image shows just fine, so you code is fine, you say the theme has thumbnail support in the functions.php file?

    add_theme_support( 'post-thumbnails' );



    David thanks for your time looking into this.

    I think I might have this wrong, I’ll explain what I was trying to do.

    I was hoping to create a simple photography gallery. I have a post for each
    section of the gallery. I have three posts with the titles Portrait, Fashion and Travel. Each of these posts have a featured image attached and a NextGen Gallery in the post with all the image for the section.

    I have a Page in WP with a title of Home(this is the first/index page). This page has home.php set as it’s template.


    So I simply wanted this home page to display each of the posts(Portrait,Fashion,Travel) featured images.


    If I add a featured image to the Home page in WP that is displayed. I think the code is working, but not to do what I wanted.

    Is it possible to display the featured image of each post on the home page?

    I really would appreciate any hep with this.

    i advice you to back up your site because some times it gives an error and ur site stops working backup it before doing anything

    todayheads – what site are you talking about?

    I haven’t posted any sites here.



    Forum Moderator

    thanks for explaining your setup.

    you need to add a query before the <?php if (have_posts()) : line to get the page template to show your choice of posts;

    example (to show 5 posts of all categories):

    <?php query_posts('cat=0&posts_per_page=5&paged='.get_query_var('paged')); ?>

    and after the <?php endif; ?> line, add:

    <?php wp_reset_query(); ?>


    Thanks alchymyth, got it working now.

    I thought query_post was when I wanted to alter the default post that just outputs the posts

    The Codex even says

    For example, on the homepage, you would normally see the latest 10 posts. If you want to show only 5 posts (and don’t care about pagination), you can use query_posts() like so:

    I see thats just the way it is but is there a reason I need the query and the post aren’t just output?

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘post_thumbnail in post?’ is closed to new replies.