Summary and Comments on Main landing Page

By default, only one post is displayed on the page

I can see several posts on your main page(6 total), please clarify what you mean.

with a small ting of comments.

Sorry, what?

More details/clarification please. Would have liked to have posted this as a comment but i’m not sure if you can quote properly there.. (feel free to down vote if anyone feels this is a misuse of the answer).

Based on the minimal information provided here’s one possible solution.

Show latest comment after each post on the index.

Assumes is_home() is true and applicable for the use case. After the <?php if( have_posts() ) ?> line, but before <?php while( have_posts() ) : ?>..

.. put the following code.

<?php if( is_home() ) $_comment_walk = new Walker_Comment; ?>

Then, just before the closing part of the while loop, that’s this part <?php endwhile; ?>, place the following..

<?php if( is_home() ) : ?>

    <div style="border:3px solid #000;padding:10px">

    <?php
    $_last_comment = get_comments( 'number=1&post_id=' . get_the_ID() );
    $_comment_walk->paged_walk( 
        $_last_comment, 0, 1, 1, 
        array( 'style' => 'div', 'avatar_size' => 40, 'max_depth' => 1 ) 
    );
    ?>

    </div>

<?php endif; ?>

NOTE: The div with the big border is just to make the box standout so you can see the result easily, remove or add to the code as you like and of course feel free to re-position it elsewhere inside the post loop if you like..(i assumed after the post was appropriate).

Why did i use the comment walker?

  • The comment gets output the same as it would in a single post instance, and the walker takes care with sanitizing for you.

Why did i set the walker before the while loop?

  • So we reuse that same walker instance, rather then creating a new one with each post iteration

Hope that helps… 🙂