How can I grab and show the reader comments of my news site in a different page?

Suppose, I have comments on a news site, into my posts. I want to show the comments (only the comments) into a different page of my site. How can I show all the news comments of my site?

Sohag, you are seeking get_comments().
See the Codex.

<?php $args= array(
    'author_email' => '',
    'ID' => '',
    'karma' => '',
    'number' => '',
    'offset' => '',
    'orderby' => '',
    'order' => 'DESC', //ASC or DESC
    'parent' => '',
    'post_id' => 0,
    'post_author' => '',
    'post_name' => '',
    'post_parent' => '',
    'post_status' => '',
    'post_type' => '',
    'status' => 'approve', //approve, hold, spam, trash
    'type' => '',
    'user_id' => '',
    'search' => '',
    'count' => false,
    'meta_key' => '',
    'meta_value' => '',
    'meta_query' => '',
);

$wpse_comments = get_comments( $args );

foreach( $wpse_comments as $s_comment ) :
    echo $s_comment->comment_author;
    echo '<br />';
    echo $s_comment->comment_content;
endforeach;

?>

Make a different Page Template and use the code into it. Hope you can figure out what the code is saying. No need to copy all the arguments from here, just take the arguments you need and rest the other in peace.

Try <?php var_dump( $wpse_comments ); ?> to see what are the properties you got with the query, and then use them accordingly.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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