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;

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.

Any help would be much appreciated!

1 Answer 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;

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.