当然这是可能的。你所要做的就是post_parent
参数到0
.
function remove_children_from_archive( $query ) {
if ( ! is_admin() && $query->is_main_query() && is_post_type_archive(\'my_custom_post_type\') ) {
// of course you\'ll have to change my_custom_post_type to real slug - probably services
$query->set( \'post_parent\', 0 );
}
}
add_action( \'pre_get_posts\', \'remove_children_from_archive\' );