Display all comments for a WordPress blog on a single page? -
what need - code perform following:
i trying setup wordpress template display comments have been posted blog. how pull comments , have same formatting applied comments under single post? such formatting occurs when comments displayed using comments.php template.
note want pull comments blog single page. still want comment pagination instead of having 20 comments under post #1, 20 under post #2, etc. want have 40 show @ 1 time on 1 page.
you want use get_comments() function.
<?php foreach (get_comments() $comment): ?> <div><?php echo $comment->comment_author; ?> said: "<?php echo $comment->comment_content; ?>".</div> <?php endforeach; ?>
see apply_filters() function apply comment output filters specific fields.
<?php echo apply_filters('comment_text', $comment->comment_content); ?>
edit:
for pagination, can use offset , number parameters of get_comments() arguments:
<?php $args = array( 'number'=>20, 'offset'=>0, 'status'=>'approve', ); foreach (get_comments($args) $comment) { // ... } ?>
Comments
Post a Comment