I have a site with a lot of pages. I would like to know if there is a method to display only the pages that I want to be displayed on the menu for choosing the parent page.

A lot of them are child pages and I don't need them to be in parent page's menu.

Does anyone know how to do it?


This meta box is printed with page_attributes_meta_box and the select field for choosing parent is generated with this code:

if ( is_post_type_hierarchical( $post->post_type ) ) :
    $dropdown_args = array(
        'post_type'        => $post->post_type,
        'exclude_tree'     => $post->ID,
        'selected'         => $post->post_parent,
        'name'             => 'parent_id',
        'show_option_none' => __('(no parent)'),
        'sort_column'      => 'menu_order, post_title',
        'echo'             => 0,

    $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
    $pages = wp_dropdown_pages( $dropdown_args );
    if ( ! empty($pages) ) :
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p>
<?php echo $pages; ?>

As you can see the function wp_dropdown_pages is used in there and you can use page_attributes_dropdown_pages_args filter to modify args for its call.

So let's say you want only top level pages in there:

function wpse_modify_parent_dropdown_args($args, $post) {
    $args['depth'] = 1;
    return $args;
add_filter( 'page_attributes_dropdown_pages_args', 'wpse_modify_parent_dropdown_args', 10, 2 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.