I want to retrieve the comments of the current post in the comments.php file. I have this:


if (comments_open()) {

    $args = array(
        'post_id' => "|what to put here ?|",
        'order'   => 'ASC'
    $comments = get_comments($args);
    <div class="comments-area">
        <h4><?php comments_number('0 Comments', '1 Comments', '% Comments'); ?> post id is <?php echo "$postid"; ?></h4>
        <?php foreach ($comments as $comment): ?>
        <ul class="comment-list">
            <li class="single-comment justify-content-between d-flex">
                <div class="user justify-content-between d-flex">
                    <div class="thumb">
                        <?php echo get_avatar( $comment->comment_author_email, 32 ); ?>
                    <div class="desc">
                        <h5><?php echo "$comment->comment_author"; ?></h5>
                        <p class="date"><?php echo "$comment->comment_date"; ?></p>
                        <p class="comment">
                            <?php echo "$comment->comment_content"; ?>
                <div class="reply-btn">
                       <a href="" class="btn-reply text-uppercase">reply</a> 
        <?php endforeach ?>

    <?php comment_form();
    echo "comments disabled";

When I put nothing in line 4: 'post_id' => "", I get all the comments in the blog. How to get only the comments of that post? I need to dynamically get the post id!

enter image description here

  • 1
    cause i dont want the regular HTML that wp_list_comments() provides i want my own HTML that i have olready writen Aug 29, 2019 at 21:03

1 Answer 1


You should be able to start your function with global $post;. Then, your $args would look like this:

$args = array(
        'post_id' => $post->ID,
        'order'   => 'ASC'
  • thank you very very much i got what i want, thanks to you. Aug 29, 2019 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.