• Resolved miocene22

    (@miocene22)


    I want my blog template to have a layout where each post has an image that is posted alongside the excerpt. Much like this site.

    I have tried the function the_post_image(); and the_post_thumbnail in my template but both give me this error:

    Fatal error: Call to undefined function the_post_image() in [thethemedirectory]\blogpage.php on line 27

    what am I doing wrong? This is the loop I made:

    <?php query_posts('category_name=websites&posts_per_page=10'); ?>
    
      <?php while (have_posts()) : the_post(); ?>
    
    		<div class="posthead">
    			<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?>
    			</a></h3>
    
    		</div><!-- /Posthead -->
    		<div class="entry">
    		 <div class="alignright"><?php the_post_image(); ?></div>
    
    			<?php the_excerpt(); ?></div><!-- /Entry -->
    
    				<p class="postmetadata">
    			<?php edit_post_link('Edit', '', ''); ?></p>
    
    	<?php endwhile; ?>

    I assume just adding an image to a post by uploading it and adding it as a thumbnail make it the post image. If I’m worng how do you add a post image to a post?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter miocene22

    (@miocene22)

    Extra: having done some research I have added add_theme_support('post-thumbnails'); to my functions.php which allows me to attach an image to my post but I still receive the same error when I visit the blog page

    Thread Starter miocene22

    (@miocene22)

    Figured it out….

    Use the_post_thumbnail() not the_post_image()

    hope this helps someone else…

    Yes it helped. Thanks a lot ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘post thumbnail’ is closed to new replies.