I am trying to add the featured image of a post into my category archive pages. My theme already supports post-thumbnail (used for the sliding top menu of the sliding doors theme).

from what I gathered I need to modify "the loop" and add the_post_thumbnail( 'thumbnail' ); somewhere in it.

Questions is where?

I tried different places and no matter what I do, nothing happens.

I tried putting it in the category.php files, same thing.

Once I get it to pop up somewhere I should be able to arrange formatting but right now, no matter what I do it's got no effect on the page.


I was able to make the thumbnail appear. My problem was that I didn't put it in the right place. Now, formatting is clearly not as easy as I thought: if I put it right after the while (have_posts() .....) it'll show, but it puts it above the post title, details, etc.

if I try to put within the existing code, no matter how I do it, the thumbnail won't show.

below is what the unmodified code loops like. I'd like to split this in 2, having the thumbnail on the left and the rest on the right.

<?php if ( in_category( _x('gallery', 'gallery category slug', 'slidingdoor') ) ) : ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

        <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'slidingdoor' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

        <div class="entry-meta">
            <?php slidingdoor_posted_on(); ?>
        </div><!-- .entry-meta -->

        <div class="entry-content">
  • 1
    It might be helpful to include the code you tried to implement. – Johannes Pille Jun 12 '14 at 17:37
  • 1
    Did you actually set an image as an "featured image" when you added the post. Remember, the post thumbnail will only return an image when it is set as an featured image, and not when an image is added to a post in the editor. – Pieter Goosen Jun 12 '14 at 17:39
  • I added the code. thanks Johannes. Pieter, yes I made sure at least one post has the set featured image. – user3617652 Jun 12 '14 at 18:35

Make sure it's inside the loop.

   <?php if (have_posts()) : ?>

<?php while ( have_posts() ) : the_post() ?>

  <?php the_post_thumbnail(); ?>

   <?php endwhile;?>

  <?php endif; ?>
  • thanks Andy. I was able to make it work. It's just that I was putting the the_post_thumbnail in the wrong spot. By putting it right after the while, it'll show, however formatting doesn't look good. I've added the original code to my question. thanks – user3617652 Jun 12 '14 at 18:37
  • Just place it anywhere after <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> You'll have to figure out where you want to place it within the html and tweak the css now! Click accept i my answer helped you. :) – andy Jun 12 '14 at 18:39
  • I can't see an accept button. and the thumbnail doesn't show if I put it as you suggested :( – user3617652 Jun 12 '14 at 18:53
  • your code doesn't look complete in your question. There's no closing statements. – andy Jun 12 '14 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.