[英]Wordpress Hide child posts of custom post type in wordpress admin
I created a custom post type called "Companies".我创建了一个名为“公司”的自定义帖子类型。 Every time a post of post type companies is created, a child post is also created.每次创建帖子类型公司的帖子时,也会创建一个子帖子。
I would like to hide the child posts of this companies post type in the backend.我想在后端隐藏该公司帖子类型的子帖子。 Is there a way to do this?有没有办法做到这一点?
Thanks!谢谢!
I managed to do this by using the following code:我设法通过使用以下代码来做到这一点:
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');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.