GeoTheme

Knowledgebase Docs » UberMenu 2 » Theme Integration
USEFUL? 5

The problem with the current version of GeoTheme is that it calls the wp_nav_menu function twice, only printing it the second time, and UberMenu will only be applied to the first.

Basically, GeoTheme is trying to check for the existence of the menu before printing it, like this:

if( wp_nav_menu( array( 'theme_location' => 'main_menu','fallback_cb' =>false,'echo' =>false) ){ 
    wp_nav_menu( array( 'theme_location' => 'main_menu', 'fallback_cb' => 'nav_nav', 'echo' => true, 'container' => 'div', 'container_id' => 'main_nav_menu' ) ); 
    ...
}else{ ?>

It generates the code for the menu, checks that something was returned, then generates the code for the menu a second time. Because UberMenu is only applied to the wp_nav_menu function the first time it is called (which was not actually printed to the site), no UberMenu is displayed – even though it was properly processed by the plugin.

At the very least, the first output should simply be captured in a variable and then printed (so that all the work of creating the menu markup doesn’t have to be executed twice). Alternatively, the standard WordPress function has_nav_menu can be used to do the check without doing all of the processing.

The solution

UberMenu 2.4.0.1+

With current versions of UberMenu, you should be able to set the Theme Location Instance to 2 (under UberMenu Control Panel > Advanced Settings ) to resolve GeoThemes’ use of the same theme location parameter.

UberMenu < 2.4

We need to only call wp_nav_menu once with this theme location. In your header.php, either replace the wp_nav_menu() call within the if statement with has_nav_menu(), like this:

Make sure you edit the wp_nav_menu call with the main_menu theme_location.

if( has_nav_menu( 'main_menu' ) ){ 
    wp_nav_menu( array( 'theme_location' => 'main_menu', 'fallback_cb' => 'nav_nav', 'echo' => true, 'container' => 'div', 'container_id' => 'main_nav_menu' ) ); 
    ...
}else{ ?>

Or, just replace the entire if/else statement with:

wp_nav_menu( array( 'theme_location' => 'main_menu' ) );
Alternatively

If you can’t edit this for some reason, your other option is to remove the double menu check from UberMenu (ubermenu/core/UberMenu.class.php line 285 or so), comment out:

if( $this->count > 0 ) return $args;

However, this solution is not recommended as it does not address the root cause of the problem, the duplication of the menu call.