Skip to main content
2 of 2
changed code block for syntax highlighting
Nicolai Grossherr
  • 18.9k
  • 8
  • 64
  • 109

The following filter shows only the top-level custom post type items in page attribute dropdowns (in main edit screen and in quick edit). Replace the 'my_custom_post_type' with your custom post type name.

function my_test($args) {
    global $post_type_object;

    if ( $post_type_object->name == 'my_custom_post_type') {
        $args['depth'] = 1;
    }
    return $args;
}
add_filter('page_attributes_dropdown_pages_args','my_test');
add_filter('quick_edit_dropdown_pages_args', 'my_test');