WordPress.org

Ready to get started?Download WordPress

Forums

Custom menu fallback not working [wp_nav_menu fallback_cb] (2 posts)

  1. Bozz
    Member
    Posted 2 years ago #

    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' ) );
    		?>
  2. Bozz
    Member
    Posted 2 years ago #

    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:
    http://pastebin.com/L5DTqfWY

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic