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.
When clicked it displays only the comments of that post in the URL
example.com/wp-admin/edit-comments.php?comment_status=all&hello_world=1
:
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' )
return;
// 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>';
}
else
{
$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.
Actions
manage_comments_custom_column
manage_comments_nav
Filters
comments_per_page
comment_status_links
admin_comment_types_dropdown
comment_edit_pre
comment_row_actions