Wordpress 删除了我的过滤器,并希望将所有内容都设置为帖子页面的默认内容
我使用unset创建了一个函数,用于在屏幕Wordpress 删除了我的过滤器,并希望将所有内容都设置为帖子页面的默认内容,wordpress,Wordpress,我使用unset创建了一个函数,用于在屏幕wp admin/edit.php中隐藏矿井过滤器: 但是,当我点击Posts菜单(wp admin/edit.php)时,默认情况下,它不会转到
wp admin/edit.php
中隐藏矿井过滤器:
但是,当我点击Posts菜单(wp admin/edit.php
)时,默认情况下,它不会转到
,而是转到我的
过滤器
如何将默认设置为
All
?我们可以截取加载过程开始时到达的页面,并检查是否需要重定向。有关逻辑,请参见注释
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();
}
});
我们可以截取加载过程开始时到达的页面(使用),并检查是否需要重定向。有关逻辑,请参见注释
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();
}
});
很好。谢谢我很好。谢谢D