Support » Fixing WordPress » Custom menu fallback not working [wp_nav_menu fallback_cb]

  • I am using a custom field to dynamically associate sub-navigation menus with specific pages. This code works well, but it does not gracefully fallback to NO menu when no MenuName custom field exists, instead displaying the default menu.

    I have tried both 'fallback_cb' => 'false' and 'fallback_cb' => '' with no success. Any ideas?

    <?php wp_nav_menu( array(
    	'fallback_cb' => 'false',
    	'sort_column' => 'menu_order',
    	'menu' => get_post_meta($post->ID, 'MenuName', true),
    	'depth'           => 2,
    	'container_class' => 'industries' ) );
Viewing 1 replies (of 1 total)
  • I should also mention I’m using this in a child theme of Twenty Eleven. I saw that fallback_cb can be affected by a pre_get_posts filter, or potentially another entry in functions.php – I have looked through and do not see any pre_get_posts filters.

    Here is the functions.php for the theme:

    My code pasted in previous post is right after get_header(); and before the_post(); in my page template.

    I would appreciate any insight on how to troubleshoot this quirk with wp_nav_menu. Thank you!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom menu fallback not working [wp_nav_menu fallback_cb]’ is closed to new replies.