WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to hook into the default Recent Comments widget to enable it to display comments for attachment posts? If so, how?

share|improve this question
up vote 1 down vote accepted

you can use the widget_comments_args filter to modify the default args of the recent comments widget:

function wpse80087_widget_comments_args( $args )
    $args = array( 'number' => 5, 'post_type' => 'attachment', 'status' => 'approve', 'post_status' => 'inherit' );
    return $args;
add_filter( 'widget_comments_args', 'wpse80087_widget_comments_args', 10, 1 );
share|improve this answer
It displays the widget title only, no comments. – Bosco Jan 10 '13 at 22:05
Yes, sorry, post_status should have been inherit, I edited my answer – diggy Jan 10 '13 at 22:13
Check that: now it displays only the comments on attachment posts. – Bosco Jan 10 '13 at 22:20
feel free to accept the answer by clicking on the check mark – diggy Jan 10 '13 at 22:39
Apologies for not being clear: Is it possible for the widget to display all comments, including attachments? 'post_type' => array('attachment', 'page', 'post'), – Bosco Jan 10 '13 at 22:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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