• 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 – https://www.ldmriviera.com.au/marine-news/

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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" />';
    		?>

    Thread Starter ramsydney

    (@ramsydney)

    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:
    https://www.ldmriviera.com.au/marine-news/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding a thumbnail image next to post excerpts on my home page’ is closed to new replies.