1

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.

Any help would be much appreciated!

2

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;?>    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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