有没有办法从评论列表中筛选回复中的评论?我基本上只想在一个单独的过滤器上看到深度1的注释。
@GhostToast Ive添加了此选项,以在管理评论面板上创建一个新的过滤器“Ask”。有没有一种方法可以将顶级注释过滤器代码应用于此Ask过滤器?这将是非常好的,因为所有评论过滤器仍然有效,并且通过只显示顶级评论来过滤提问。。。
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[\'ask\'] ) )
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\'] = 12;
}
/**
* Add link to specific post comments with counter
*/
function wpse_63422_new_comments_page_link( $status_links )
{
$count = get_comments( \'post_id=12&count=1\' );
if( isset( $_GET[\'ask\'] ) )
{
$status_links[\'all\'] = \'All\';
$status_links[\'ask\'] = \'Ask (\'.$count.\')\';
}
else
{
$status_links[\'ask\'] = \'Ask (\'.$count.\')\';
}
return $status_links;
}