Include Private/Draft Pages In Parent Dropdowns

Screen Shot 2014-09-02 at 3.52.08 PMBy default, WordPress only includes published pages in the dropdown select menu that allows you to choose a parent for a particular page. This is a pretty well documented problem that is yet to be addressed in core. Not a huge issue, however it can cause some pretty pesky problems.

For example, say you have a parent page and a child page that aren’t quite ready to share with the world, so you want to make them private. So you edit the parent page and set it to private. Then you go to the child page to set it to private. Alas, the parent page will no longer appear in the dropdown “parent” menu, and thus if you save the child page at all, it becomes parentless. No fun, right?

So this snippet fixes that problem by adding private and pending (awaiting review) pages to the parent dropdown menu – and it works for bulk editing, quick editing, and editing in a single page view. If you want to tweak the post_status types that are included, just edit the array listed in the code, using values from the WP_Query codex page.

/**
 * Show all parents, regardless of post status.
 *
 * @param   array  $args  Original get_pages() $args.
 *
 * @return  array  $args  Args set to also include posts with pending, draft, and private status.
 */
function my_slug_show_all_parents( $args ) {
	$args['post_status'] = array( 'publish', 'pending', 'draft', 'private' );
	return $args;
}
add_filter( 'page_attributes_dropdown_pages_args', 'my_slug_show_all_parents' );
add_filter( 'quick_edit_dropdown_pages_args', 'my_slug_show_all_parents' );

Newsletter

Subscribe and stay connected through our Newsletter. We send out important news, tips and special offers.

  • This field is for validation purposes and should be left unchanged.