Support » Fixing WordPress » Modifying comments so they show on the home page

  • Hello!

    I just got finished setting up my blog, which you can see here:

    http://crossfitcostamesa.com/blog/

    I’d really like the comments from each post to show up on the front page of the site. Here’s a similar site, using WordPress that has the function that I want:

    Home Page

    The post titled “Welcome to The Family Luke” has a comment and it’s displaying on the main page.

    Can anyone help me configure my site so I can have my comments post on the front page?

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Looks like it is just a widget named recent comments or latest comments. Nothing special. Just activate it in your Dashboard/Widgets.

    I’m actually wanting the comments to show up below the post on the front page, not on the left hand rail. Any idea how to do that?

    Anyone?

    Same problem here. Did you figure it out?

    No, nothing yet. Have you posted a thread anywhere else?

    No. This seems to be a popular question, yet there is no answer. Frustrating.

    GOT IT! Try this. Be sure to put it on the main index template. Good luck:

    Normally, we will put a recent comment widget on the sidebar of our blog. That widget will show all recent comments taken from all posts. But now, we want to do something different. We want to show the recent comment(s) for each of our post on the main page. Something like the Gizmodo (but of course they are not using WordPress). The recent comment(s) can be shown under each post, or next to it, depends on your theme and CSS styling. It will definitely look good on a grid theme.

    Code Implementation
    Here is the way to implement it. Open your index.php file, and paste the following code inside the Loop, anywhere before the <?php endwhile; ?>. Preferably after <?php the_content(); ?>.

    <!-- recent comment of each post -->  
    
    <div class="recent-comment">
     <?php
        $comment_array = array_reverse(get_approved_comments($wp_query->post->ID));
        $count = 1;
     ?>  
    
    <?php if ($comment_array) {  ?>
        <span class="comment"> <?php comments_number('No comment','1 comment','% comments'); ?></span> - Latest by:
        <ul class="commentlist">
            <?php foreach($comment_array as $comment){ ?>
                <?php if ($count++ <= 2) { ?>  
    
    <li><?php comment_author_link(); ?>  <?php comment_excerpt(); ?> </li>
                <?php } ?>
            <?php } ?>  
    
    <?php } else { ?> <!-- if there was no comment in that post,yet -->
            <span class="comment">No comment so far</span>
    <?php } ?>
    </div>  
    
    <!-- end recent comment-->
    <!-- recent comment of each post -->
    
    <div class="recent-comment">
     <?php
    	$comment_array = array_reverse(get_approved_comments($wp_query->post->ID));
    	$count = 1;
     ?>
    
    <?php if ($comment_array) {  ?>
    	<span class="comment"> <?php comments_number('No comment','1 comment','% comments'); ?></span> - Latest by:
    	<ul class="commentlist">
    		<?php foreach($comment_array as $comment){ ?>
    			<?php if ($count++ <= 2) { ?>
    
    <li><?php comment_author_link(); ?>  <?php comment_excerpt(); ?> </li>
    			<?php } ?>
    		<?php } ?>
    
    <?php } else { ?> <!-- if there was no comment in that post,yet -->
    		<span class="comment">No comment so far</span>
    <?php } ?>
    </div>
    
    <!-- end recent comment-->

    Some explanation: this will fetch comment for each post, with the help of Post ID and will display latest 2 comments. You can change that count to any number you want. You just have to modify the line that says <?php if ($count++ <= 2) { ?>. Simple, right?

    So that proper credit is given, the above solution comes from flisterz:blog*

    If you’re going to cut and paste someone else’s material, you should at least provide a link to the source. Otherwise it seems as if you’re trying to pass it off as your own. No one appreciates having their work stolen or plagiarized.

    @ctworden: please mark this post as resolved, since I see you have this implemented on your site. Looks great!

    You could have just said…

    You can also find the original source here…
    *LINK*

    optimistsonly never said he wrote it…

    It’s hardly something you could claim as your own code anyway, it’s a few lines of basic PHP.

    So if you’re going to give “PROPER” credit, then you should actually link here.

    http://php.net/

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Modifying comments so they show on the home page’ is closed to new replies.