Forums

[resolved] post thumbnail (4 posts)

  1. miocene22
    Member
    Posted 2 years ago #

    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?

  2. miocene22
    Member
    Posted 2 years ago #

    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

  3. miocene22
    Member
    Posted 2 years ago #

    Figured it out....

    Use the_post_thumbnail() not the_post_image()

    hope this helps someone else...

  4. hilj
    Member
    Posted 2 years ago #

    Yes it helped. Thanks a lot :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags