WordPress.org

Ready to get started?Download WordPress

Forums

How do you get comments to display under index page post (4 posts)

  1. just wondering
    Member
    Posted 5 years ago #

    I thought I had seen this topic on here before and have looked but cannot find it.

    I only have from zero to two or three comments per post.

    What I'd like to do is display the comments without the viewer having to click "1 comment" or "2 comments" to get them to expand for example.

    I could see where it would be a problem to do this if I 50/60 comments per post. But I only keep 5 post per page and like I said above I have from zero to two or three comments per post, mostly zero.

    Any ideas or directions to ideas?

    Thanks
    Steve J

  2. stvwlf
    Member
    Posted 5 years ago #

    Hi

    Your idea makes sense.

    What you need to do is copy the comment displaying code from your theme's single.php file and paste it into the theme's index.php file inside the loop. It needs to be inside the loop so it will appear after each post and not just once after the last post has displayed.

    Be sure to make a copy of index.php as it is now before you change anything, just in case.

    Then experiment with the comment code until you get it in the right place in index.php. It will help if you are looking at a single post page on your site while you examine the single.php code, so you can see the correlation between each section of code and the output on the screen. Its not necessary that you understand the code, just move it as a block and it will do the same thing on index.php as it does on single.php

  3. beejoy
    Member
    Posted 5 years ago #

    Hi Stvwlf

    I am trying to do the same thing and I have done what you suggest above and placed the code from the single.php
    <div class="comment"></div> <!-- Closes Comments --><?php comments_template(); ?>

    I have placed this code above before (<?php endwhile; ?>) and between (<?php endwhile; ?>) and this (<?php else : ?>)and also after (<?php else : ?>) and before this code (<?php endif; ?>) and no change to display of comments on index page.

    I am using the Studiopress theme what am I doing wrong
    would appreciate your help

    Cheers

    BJ

  4. ANAdesigns
    Member
    Posted 4 years ago #

    This was driving me crazy until I found most of the answer in another post.

    I use this code in archives.php and it does exactly what I want it to do, which is display the full comment and option to reply instead of the "click for comments" link. I've tested this in two WP sites with different themes. No problems.

    In the appropriate file, replace the code that looks something like this:

    <p class="postmetadata"><?php the_tags(); ?><?php edit_post_link('Edit',' ',''); ?> <br /><?php comments_popup_link('Click here to Comment on this post', '1 Comment- click to read', '% Comments - click to read'); ?>
    </p>

    With this code:

    <?php
      $withcomments = "1";
      comments_template();
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic