0

So I wanted to display the 10 most recent comments from my blog onto my homepage.

Can anyone tell me how to do that? preferably without using a plugin if possible...

thank you.

1
  • I assume you were also looking for a solution without using a widget as well...
    – Giraldi
    Commented Jan 15, 2015 at 22:28

1 Answer 1

2

You can do that with get_comments.

<?php
$comments = get_comments(array(
    'number'      => 10, // 10 comments
    'status'      => 'approve', // only approved comments
    'post_status' => 'publish', // only on published posts
));

// do stuff with $comments

You can see how the core itself does this in the recent comments widget.

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.