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

I found so many information and most of the tutorials only talk about adding filter in post/custom post only.

I want to do something similar to this tutorial in 'Comments' area in admin panel.

Add filter menu to admin list of posts (of custom type) to filter posts by custom field values

However, I'm not sure if the parse_query handle also handle the query in this area? Anyone might have suggestion on tutorial, plugin that might help?

share|improve this question

Working Example [Update]

From this Answer, by @TheDeadMedic, here's an adaptation to show only comments from a specific post_id. A link to this action is inserted in the status row.

Hello World is the post with ID 53.

new comments status link

When clicked it displays only the comments of that post in the URL

show comments of only one post

add_action( 'current_screen', 'wpse_72210_comments_exclude_lazy_hook', 10, 2 );

 * Delay hooking our clauses filter to ensure it's only applied when needed.
function wpse_72210_comments_exclude_lazy_hook( $screen )
    if ( $screen->id != 'edit-comments' )

    // Check if our Query Var is defined    
    if( isset( $_GET['hello_world'] ) )
        add_action( 'pre_get_comments', 'wpse_63422_list_comments_from_specific_post', 10, 1 );

    add_filter( 'comment_status_links', 'wpse_63422_new_comments_page_link' );

 * Only display comments of specific post_id
function wpse_63422_list_comments_from_specific_post( $clauses )
    $clauses->query_vars['post_id'] = 53;

 * Add link to specific post comments with counter
function wpse_63422_new_comments_page_link( $status_links )
    $count = get_comments( 'post_id=53&count=1' );

    if( isset( $_GET['hello_world'] ) ) 
        $status_links['all'] = '<a href="edit-comments.php?comment_status=all">All</a>';
        $status_links['hello'] = '<a href="edit-comments.php?comment_status=all&hello_world=1" class="current">Hello World ('.$count.')</a>';
        $status_links['hello'] = '<a href="edit-comments.php?comment_status=all&hello_world=1">Hello World ('.$count.')</a>';

    return $status_links;

Useful Hooks

Search for the hooks bellow, they are available in the file /wp-admin/includes/class-wp-comments-list-table.php.

It'll give you a panorama of the possibilities for the Comments screen.



share|improve this answer

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.