Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.