Get comments for specific post outside the loop

Home Forums PHP Development Get comments for specific post outside the loop

This topic contains 4 replies, has 3 voices, and was last updated by  tritandominic 4 years, 4 months ago.

  • #965


    Participant

    Trying to get comments for a post, but I can’t get it to work. Here’s the code:
    <?php
    $comments = get_comments('$post_id');
    foreach($comments as $comment) : ?>
    <div>
    <ul>
    <li>
    <?php echo ($comment->comment_content); ?>
    </li>
    </ul>
    </div>
    <?php endforeach; ?>

You must be logged in to reply to this topic.