Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Dashboard > Comments = Filter by post WordPress


Would like to be able to filter the Dashboard > Comments by post.

Ideally choosing the post from a dropdown menu and only showing the comments submitted to it within the Dashboard > Comments list.

Not looking for a plugin.

Answers (3)


Dbranes answers:

I agree that it might not be ideal to do this, but one can add this filter via the <em>restrict_manage_comments </em> and <em>comments_clauses </em> hooks like this:

add_action('restrict_manage_comments', 'restrict_manage_comments_callback' );
add_filter('comments_clauses', 'comments_clauses_callback' );

function restrict_manage_comments_callback(){?>
<select name='mypostid' class='commentform'>
<option value=""> <?php _e( 'Posts' ); ?> </option>
$posts = get_posts( array( 'posts_per_page' => -1, 'orderby' => 'comment_count', 'order' => 'DESC' ) );
foreach( $posts as $post ):
printf('<option value="%d" %s>%s (%d)</option>', $post->ID, selected( $post->ID, $_GET['mypostid'] ),$post->post_title, $post->comment_count );
function comments_clauses_callback( $clauses ){
if( isset($_GET['mypostid']) && $_GET['mypostid'] >0 ) {
$clauses['where'] .= sprintf( " AND comment_post_ID = %d ", $_GET['mypostid'] );
return $clauses;

Dbranes comments:

... did it work for you?


Abdelhadi Touil answers:

Have you tried to click on comments number for a specific post? This will list all comments for this specific post.
From comments secition, in the last column called "In Response To" you can see the comments number, click on it and done :)

leannekera comments:

Yup that works great, but I require the posts as a dropdown within the top of the full list, as my clients wont know to do that.

Abdelhadi Touil comments:

I think it wont be useful while there are many posts published, the dropdown menu will be useless.. You can also go to Posts section and you'll se the number of comments in the right of each post, just click on it and you'll have all comments of this specific post. So now you have two way: From comments section, or from posts section. I think is better than dopdown menu :)


Navjot Singh answers:

I hope your client are running blogs with few posts only. This option won't be practical for even a couple of hundred posts, forget thousand.

Navjot Singh comments:

And not to forget the amount of HTML which will be generated on each comment page for it. This option is not very feasible.

leannekera comments:

Yes the posts are automatically removed once the date is hit as they are being used as events.