除了我之前的答案之外,添加以下代码。应该很好用
add_filter( \'views_edit-books\', \'add_filter_link\' );
function add_filter_link( array $views ) {
$url = add_query_arg( array(\'bfilter\'=>\'parents\',\'post_parent\'=>0,\'post_type\'=>\'books\'), \'edit.php\' );
$views[ \'post_parent\' ] = sprintf(
\'<a href="%1$s"%2$s>%3$s</a>\',
esc_url( $url ),
( is_filter_active() ) ? \' class="current" aria-current="page"\' : \'\',
\'Post Parents\'
);
return $views;
}
function is_filter_active() {
return (filter_input( INPUT_GET, \'bfilter\' ) ===\'parents\');
}
如果您还没有使用下面的代码,那么也添加该代码
function make_post_parent_public_qv() {
global $pagenow;
if ( is_admin() && $pagenow == \'edit.php\' )
$GLOBALS[\'wp\']->add_query_var( \'post_parent\' );
}
add_action( \'init\', \'make_post_parent_public_qv\' );