I had a client who asked me to keep some pages set to
draft so they would not be visible in the
wp_nav_menu() but this did not work as expected. By default, setting a page’s status to
draft after it was added to a navigation menu had no effect. So I poked around in
lib/nav.php and came up with this.
I edited line 38 of
lib/nav.php from this:
$output .= $item_html;
$output .= get_post_status($item->object_id) == 'publish' ? $item_html : '';
I suppose it might make for faster code execution to wrap the entire
start_el() function in an if statement, but this was fine for my needs.
Rather surprised this is not default behavior, but this tidbit works like a charm. Enjoy!