No hierarchy of pages when adding pages to nav menus with too many pages

WordPress had problems with hierarchy on Menu page in history. There was no hierarchy at all for pages on View All tab. Now, it is fixed. At first glance. When you have more than 50 pages, you’ll run into problem.

Your pages will be divided to two or more pages. The first page is OK, second and next not. On second and next page, there are pages without hierarchy. This makes it almost imposible to setup a nav menu.

I have a quick fix for this issue. It will remove the mentioned pagination and will display reall „All“ pages on single tab. Copy and paste the following WordPress snippet to your functions.php.

function binda_modify_nav_menu_items_page( $posts, $args, $post_type ){
	global $_nav_menu_placeholder, $nav_menu_selected_id;

	$post_type_name = $post_type['args']->name;

	$args = array(
		'offset' => $offset,
		'order' => 'ASC',
		'orderby' => 'title',
		'posts_per_page' => -1,
		'post_type' => $post_type_name,
		'suppress_filters' => true,
		'update_post_term_cache' => false,
		'update_post_meta_cache' => false
	);

	if ( isset( $post_type['args']->_default_query ) )
		$args = array_merge($args, (array) $post_type['args']->_default_query );

	$get_posts = new WP_Query;
	$posts = $get_posts->query( $args );

	if ( !$posts )
		$error = '
  • '. $post_type['args']->labels->not_found .'
  • '; // if we're dealing with pages, let's put a checkbox for the front page at the top of the list if ( 'page' == $post_type_name ) { $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0; if ( ! empty( $front_page ) ) { $front_page_obj = get_post( $front_page ); $front_page_obj->front_or_home = true; array_unshift( $posts, $front_page_obj ); } else { $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; array_unshift( $posts, (object) array( 'front_or_home' => true, 'ID' => 0, 'object_id' => $_nav_menu_placeholder, 'post_content' => '', 'post_excerpt' => '', 'post_parent' => '', 'post_title' => _x('Home', 'nav menu home label'), 'post_type' => 'nav_menu_item', 'type' => 'custom', 'url' => home_url('/'), ) ); } } return $posts; } add_action ( 'nav_menu_items_page', 'binda_modify_nav_menu_items_page', 1, 3 ); add_action( 'admin_print_styles-' . 'nav-menus.php', 'binda_nav_menu_custom_css' ); function binda_nav_menu_custom_css() { echo '#posttype-page .add-menu-item-pagelinks{display:none;}'; }