Please can someone tell me how to remove all items from the 'Parent' drop down when creating a page apart from a few items? (Loop through and remove all that are the ones I want).


You can use the page_attributes_dropdown_pages_args filter to remove whatever you want. It's based off of the wp_dropdown_pages() arguments so you can use the exclude parameter to remove certain pages or a fake parent to remove all the pages:

 * Filter the arguments of Page Attributes Parent Dropdown
 * @param Array $args - List of wp_dropdown_pages() arguments
 * @param WP_Post Object $post - Current post object
 * @retun Array $args - List of wp_dropdown_pages() arguments
function admin_page_attributes_meta_filter( $args, $post ) {

    $args['exclude'] = array( 1 );      // Exclude page ID 1 from the dropdown list

     * Uncomment to exclude all pages
     * $args['child_of'] = -1;

    return $args;

add_filter( 'page_attributes_dropdown_pages_args', 'admin_page_attributes_meta_filter', 10, 2 );
  • Thats great thanks! Just a note to others, you can use the code to exclude all pages and then $args['include'] to set certain parent pages if required.
    – LB79
    Aug 21 '17 at 18:02

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.