Here's my PHP code:
<?php
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query( array( 'number' => 5 ) );
if ($comments)
{
foreach ( $comments as $comment ) {
?>
<div class="comment" id="comment-<?php $comment->comment_ID ?>">
<div class="avatar">
<?php get_avatar( $comment->comment_author_email, 48 ); ?>
</div>
<div class="text>
<a class="author" href="<?php get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; ?>">
<?php get_comment_author( $comment->comment_ID ) ?>
</a>
<?php strip_tags( substr( apply_filters( 'get_comment_text', $comment->comment_content ), 0, 80 ) ) . '...'; ?></p>
</div>
</div>
<?php
}
} else {
echo 'none.';
}
?>
Here is the resulting HTML of one comment:
<div class="comment" id="comment-">
<div class="avatar">
</div>
<div class="text>
<a class=" author"="" href="">
<p></p>
</div>
</div>
I have comments so the 'none.' is not printed. However, as you can see, the comment object is empty. What am I missing/what's going on?
I'm running WP 4.2.2.
Thanks, Joshua
got it, something stupid, but even though I was calling the methods, I wasn't
echo
ing the results.