我创建了各种自定义的post状态选项(如默认选项:“published”、“draft”等),其中一个选项是“project closed”。我需要从后端的帖子列表中默认隐藏/排除在“项目关闭”帖子状态下设置的帖子。
有办法做到这一点吗?非常感谢你!
我创建了各种自定义的post状态选项(如默认选项:“published”、“draft”等),其中一个选项是“project closed”。我需要从后端的帖子列表中默认隐藏/排除在“项目关闭”帖子状态下设置的帖子。
有办法做到这一点吗?非常感谢你!
不清楚您在这里要找什么,但您可以尝试使用posts_where
过滤器:
/**
* Remove posts, with a given status, on the edit.php (post) screen,
* when there\'s no post status filter selected.
*/
add_action( \'posts_where\', function( $where, $q )
{
if( is_admin()
&& $q->is_main_query()
&& ! filter_input( INPUT_GET, \'post_status\' )
&& ( $screen = get_current_screen() ) instanceof \\WP_Screen
&& \'edit-post\' === $screen->id
)
{
global $wpdb;
$status_to_exclude = \'project_close\'; // Modify this to your needs!
$where .= sprintf(
" AND {$wpdb->posts}.post_status NOT IN ( \'%s\' ) ",
$status_to_exclude
);
}
return $where;
}, 10, 2 );
您必须修改$status_to_exclude
地位在这里,我们的目标是edit.php
的屏幕post
岗位类型。我们确保post_status
未设置GET筛选器。因此,当您单击后端中的“所有帖子”管理菜单链接时,此筛选将被激活。
希望您可以根据自己的需要进一步调整。
我有一个自定义的帖子类型,它将展示用户提交的图像,目前,检查用户上传的图像是一项枯燥的任务——我必须进入每个帖子,检查特色图像,然后发布。理想情况下,我希望能够在管理中显示这样的自定义帖子类型:在愿望中,我拉通过特色图像,可以发布或删除它那里,然后。而不是以前的处理方式。有没有办法自定义帖子类型的页面?我还没有找到任何解决办法。非常感谢任何链接或代码!