WordPress.org

Ready to get started?Download WordPress

Forums

Adding a thumbnail image next to post excerpts on my home page (3 posts)

  1. ramsydney
    Member
    Posted 2 years ago #

    I have set up my home page to show only post excerpts. It looks quite boring so would like to add a thumbnail size version of the image that appears in the full-size post, next to each excerpt. I have created my own version of the Twenty Eleven theme which I have edited.

    Here is a link to the site - http://www.ldmriviera.com.au/marine-news/

    Thanks in advance.

  2. zex2911
    Member
    Posted 2 years ago #

    Do you have 'Featured image' option while creating post? If yes, that you can call it in your page.php inside loop before excerpt (or what ever page template you are using) with something like this

    <?php if (has_post_thumbnail($post->ID))
            the_post_thumbnail( 'thumbnail' );
            else
    	echo '<img src="' . bloginfo( 'template_url' ) . '/images/mix-of-sites.png" alt="picture" />';
    		?>
  3. ramsydney
    Member
    Posted 2 years ago #

    Thanks for that, zex2911.

    Yes, I have the 'Featured image' option. As instructed, I inserted the code into page.php. Then added a new post and selected 'Featured image' when inserting the photo, however it didn't seem to work.

    Below is the code on my page.php page. Is this correct?

    get_header(); ?>
    
    <div id="primary">
    <div id="content" role="main">
    
    <?php while ( have_posts() ) : the_post(); ?>
    
    <?php get_template_part( 'content', 'page' ); ?>
    
    <?php comments_template( '', true ); ?>
    
    <?php if (has_post_thumbnail($post->ID)
       the_post_thumbnail( 'thumbnail' );
       else
    echo '<img src="' . bloginfo( 'template_url' ) . '/images/mix-of-sites.png" alt="picture" />';
    		?>
    
    <?php endwhile; // end of the loop. ?>
    
    </div><!-- #content -->
    </div><!-- #primary -->
    
    <?php get_footer(); ?>

    Here is the link again where it still looks the same:
    http://www.ldmriviera.com.au/marine-news/

Topic Closed

This topic has been closed to new replies.

About this Topic