我有这段代码一直工作,但在更新到Wordpress 4.2.1后,这不起作用。
// return just the missing replies in the comment table
add_action( 'pre_get_comments', array( $this, 'return_missing_list' ) );
public function return_missing_list( $comments = array() ) {
// bail on anything not admin
if ( ! is_admin() )
return;
// only run this on the comments table
$current_screen = get_current_screen();
if( 'edit-comments' !== $current_screen->base )
return;
// check for query param
if ( ! isset( $_GET['missing_reply'] ) )
return;
// now run action to show missing
$comments->query_vars['meta_key'] = '_cnrt_missing';
$comments->query_vars['meta_value'] = '1';
$comments->query_vars['date_query'] = array(
'after' => '10 months ago'
);
// Because at this point, the meta query has already been parsed,
// we need to re-parse it to incorporate our changes
$comments->meta_query->parse_query_vars( $comments->query_vars );
} // end missing_reply_list