• I am attempting to use the_post_thumbnail tag on a main page template, and it does not work. The code below I’m using is a modified version from Pages – A Page of Posts

    Can anyone tell me why the_post_thumbnail tag isn’t working? I’ve enabled post thumbnails by adding add_theme_support('post-thumbnails'); to the theme’s functions.php file, but still no thumbnail display.

    Thanks

    <?php if( $my_query->have_posts() ) : ?>
    		<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    			<?php
    			//necessary to show the tags
    			global $wp_query;
    			$wp_query->in_the_loop = true;
    			?>
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<?php the_post_thumbnail(); ?>
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    				<div class="entry">
    					<?php the_excerpt(); ?>
    				</div>
    			</div>
    		<?php endwhile; ?>
    
    	<?php else : ?>
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    	<?php endif; ?>
  • The topic ‘the_post_thumbnail not working’ is closed to new replies.