Wordpress 隐藏子项 posts of custom post type in wordpress admin
Wordpress Hide child posts of custom post type in wordpress admin
我创建了一个名为“公司”的自定义 post 类型。
每次创建 post 个 post 类型的公司时,也会创建一个子 post。
我想在后台隐藏这家公司 post 的子 post 类型。
有办法吗?
谢谢!
我使用以下代码设法做到了这一点:
function cleanup_companies_posttype_list($query) {
global $pagenow;
if (isset($_GET['post_type']) && $_GET['post_type'] == 'companies' && $pagenow == 'edit.php') {
$query->set('post_parent',0);
}
}
add_filter('pre_get_posts', 'cleanup_companies_posttype_list');
我创建了一个名为“公司”的自定义 post 类型。 每次创建 post 个 post 类型的公司时,也会创建一个子 post。
我想在后台隐藏这家公司 post 的子 post 类型。 有办法吗?
谢谢!
我使用以下代码设法做到了这一点:
function cleanup_companies_posttype_list($query) {
global $pagenow;
if (isset($_GET['post_type']) && $_GET['post_type'] == 'companies' && $pagenow == 'edit.php') {
$query->set('post_parent',0);
}
}
add_filter('pre_get_posts', 'cleanup_companies_posttype_list');