0

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

1 Answer 1

1

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 );
5
  • It displays the widget title only, no comments.
    – Bosco
    Commented Jan 10, 2013 at 22:05
  • Yes, sorry, post_status should have been inherit, I edited my answer
    – diggy
    Commented Jan 10, 2013 at 22:13
  • Check that: now it displays only the comments on attachment posts.
    – Bosco
    Commented Jan 10, 2013 at 22:20
  • Apologies for not being clear: Is it possible for the widget to display all comments, including attachments? 'post_type' => array('attachment', 'page', 'post'),
    – Bosco
    Commented Jan 10, 2013 at 22:45
  • Works perfect! To merge all comments you limit it to 'status' => 'approve' Thanks!
    – Bosco
    Commented Jan 10, 2013 at 22:58

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.