You can add the future pages with the filter nav_menu_items_page
Notes:
- You can do the same with the posts or other cpt by changing the post
type in the hooknav_menu_items_{$post_type}
- This filter is for the View All tab in the pages.
Example:
function add_scheduled_pages($posts, $args, $post_type) {
$query = new WP_Query(
array(
'post_type' => 'page',
'post_status' => array('publish', 'future')
)
);
$posts = $query->posts;
return $posts;
}
add_filter( 'nav_menu_items_page', 'add_scheduled_pages', 10, 3 );
Now you can add futures pages to the menu but this pages will show in the front end menu too.
So now you need to filter all the future pages and remove them from the front end.
Its can be done with the filter wp_nav_menu_objects
function remove_future_pages($sorted_menu_items, $args) {
$filter_futures = array_filter($sorted_menu_items, function($item) {
if(get_post_status($item->object_id) !== 'future') {
return $item;
}
});
return $filter_futures;
}
add_filter( 'wp_nav_menu_objects', 'remove_future_pages', 10, 2 );