wp-admin/edit.php我使用 unset制作了一个在屏幕中隐藏 Mine 过滤器的函数:

但是,当我单击“帖子”菜单 ( wp-admin/edit.php) 时,默认情况下不会进入All,它仍然会进入Mine过滤。
如何将其设置为默认值All?
我们可以拦截加载过程一开始到达的页面(使用load-(page))并检查是否需要重定向。逻辑见评论。
add_action( 'load-edit.php', function()
{
global $typenow;
// Not our post type, bail out
if( 'post' !== $typenow )
return;
// Administrator users don't need this, bail out
if( current_user_can('add_users') )
return;
// Only the Mine tab fills this conditions, redirect
if( !isset( $_GET['post_status'] ) && !isset( $_GET['all_posts'] ) )
{
wp_redirect( admin_url('edit.php?all_posts=1') );
exit();
}
});
Run Code Online (Sandbox Code Playgroud)