• Resolved shibonari

    (@shibonari)


    Hi there, I have some questions regarding wp_list_comments

    This is the code in my index.php:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2 class="title"><?php the_title(); ?></h2>
    
    <div class="reply" id="reply_content_<?php the_ID(); ?>">
    <?php require("comments.php"); ?>
    </div> 
    
    <?php endwhile; ?>
    <?php endif; ?>

    and I just copied the default comments.php.

    If I understand correctly, the <?php wp_list_comments(); ?> in the comments.php should list all the comments right?

    I’m sorry if I had mistaken it. Any help on how can I display all the comments and the comment reply box for the post in the index?

    Thanks in advance 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • If I understand correctly, the <?php wp_list_comments(); ?> in the comments.php should list all the comments right?

    Yes

    http://codex.wordpress.org/Template_Tags/wp_list_comments

    Rather then doing..

    <?php require("comments.php"); ?>

    You can just use..

    <?php comments_template(); ?>

    WordPress will call comments.php from your theme as necessary..
    http://codex.wordpress.org/Include_Tags#The_Comments_Template

    Thread Starter shibonari

    (@shibonari)

    Hello, thanks for all the responses 😀

    I tried

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2 class="title"><?php the_title(); ?></h2>
    
    <div class="reply" id="reply_content_<?php the_ID(); ?>">
    <?php comments_template(); ?>
    </div> 
    
    <?php endwhile; ?>
    <?php endif; ?>

    And I got nothing 🙁

    No comments list, no comment reply box.

    All I’m trying to do is just display all the post and their comments in the index. :\

    From the area of the page i linked to above.

    This tag includes the file comments.php from your current theme’s directory. If that file is not found, it will instead include wp-content/themes/default/comments.php. To display comments on the main index or archive pages, you’ll need to set the $withcomments variable to “1” before calling this tag.

    Thread Starter shibonari

    (@shibonari)

    Thanks alot!

    Silly me, I was trying all sorts of stuffs like <?php comments_template(1); ?> and etc but I just realized that I can just add $withcomments = 1;!

    Thanks alot for the help, really appreciated it 🙂

    No problem… 😉

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘wp_list_comments and listing comments’ is closed to new replies.