Load comments.php template outside the post loop

I’m loading a post via ajax and outputting using
$post = get_post( $post_ID );
Is there a way to load the comments.php template after I’ve output my post? I tried using:

global $withcomments;
$withcomments = true;
comments_template(); 

But it’s not within the loop so it’s not loading the template. I’m trying to get my comment form and any current comments to display, just having some difficulties.

Read More

Any help would be much appreciated!

Related posts

1 comment

  1. So apparently this is a big no-go, but I’ve been able to build my own custom comments form and loop using this code:

    <?php $args = array(
          'post_id' => $post_ID);
    
    $comments = get_comments($args);
    
    if($comments) :
        foreach($comments as $comment) :?>
            <div class="comment"><?php print_r($comment); ?></div>
        <?php endforeach;
    endif;?>    
    

Comments are closed.