• Hi folks,

    I’ve managed to build a custom category page template that displays all posts from the parent category and child categories too. You can see it in action here:

    The Sisters Cafe custom category page

    I’d like to display featured images for each of my posts but whenever I call the post thumbnail, it displays the same image repeatedly at the top of the page instead of next to the title. Where am I going wrong?

    Here is the code:

    $cat_id = get_query_var('cat');
        $categories=get_categories('child_of=' . $cat_id);
    	foreach ($categories as $cat)
        {
            $tmpPosts = get_posts('category=' . $cat->cat_ID);
            if (count($tmpPosts) > 0)
    		{
    			echo '<strong>' . $cat->name . '</strong>';
    			echo '<ul>';
    
    			foreach ($tmpPosts as $post)
    			{ ?>
    			<li>THUMBNAIL HERE<a href="<?php get_page_link($post->ID); ?>" title="<?php $post->post_title; ?>"><?php $post->post_title; ?></a></li>
    			<?php }
    			echo '</ul>';
    		}
        }

    This is just for the child category posts. When I use:

    the_post_thumbnail('teaser-image')

    For the parent category posts it works perfectly, but doing the same for the child category code produces the same repeated image above all the post titles.

    Any help would be appreciated, I know it is something to do with the way I’m calling the posts.

  • The topic ‘Post thumbnails don't work on custom category template’ is closed to new replies.