Caching Plugins – Menu intermittently displays as unstyled list or default menu

Knowledgebase Docs » UberMenu 2 » FAQs
USEFUL? 7
UberMenu 2

Recommended: If you are using a caching plugin, you should disable the Default to theme menu in IE6 setting in the UberMenu Control Panel > Theme Integration. You don’t want your caching plugin to cache a non-UberMenu version of the page. (Don’t forget to clear the server cache after changing the setting).

If you have disabled the Default to IE6 setting and are still having issues, read on

Some users have reported issues with caching plugins such as W3TC (W3 Total Cache). The symptom is that the menu is intermittently displayed as an unstyled list on cached pages.

I’ve investigated this issue, and the cause is that the page caching program has not cached the UberMenu markup in the static cache file – instead, it seems to revert to either the theme’s markup, or some default markup for the menu, thereby resulting in the unstyled list of menu items.

In other words, UberMenu is not being displayed at all. Codewise, UberMenu’s display is a combination of two things: HTML and CSS. The CSS (stylesheets) are still loaded; however, the static cached page does not display the UberMenu-generated HTML markup. As a result, there is nothing for the CSS to style (the elements which the CSS targets do not exist). The menu being displayed is not UberMenu at all, and that is the problem.

To my knowledge, there is nothing UberMenu can do to change how the caching plugin chooses to cache the page. UberMenu follows all of the WordPress standards to create the menu markup (via filters and custom navigation walkers).

Please note: I am not sure if this is an issue with the caching plugin itself, the underlying server caching modules, or with the way the plugin has been configured on a particular site. It takes some expertise to properly configure a caching plugin.

For help with caching issues, I recommend contacting the author of the caching plugin, as they will certainly have better insight into how the caching works. If there are any recommendations that will help the menu and caching plugin be more compatible, I am certainly willing to consider them.

Potential Solution 1: Dynamic Caching

One potential solution is to use the caching plugin mfunc functionality. For example, in WP-Super Cache this may help (different plugins may use different syntax, check your caching plugin’s documentation for details on “dynamic caching”)

<!-- mfunc wp_nav_menu( $args ); --> 
<?php wp_nav_menu( $args ); ?>
<!-- /mfunc --> 

Note that $args may be a variable or an array, and it is my understanding that both the code after the mfunc and within the PHP tags must match.

Potential Solution 2: Direct Integration (UberMenu v2.3+)

Another possibility is that the caching plugin may not be capturing filtered values properly. Using direct integration bypasses the menu argument filters, so if this is the problem it should alleviate it. Replace your existing wp_nav_menu() call with

<?php if( function_exists( 'uberMenu_direct' ) ) uberMenu_direct( 'primary' ); ?>

Where ‘primary’ is your theme location handle/ID/slug. That means that whatever the value for ‘theme_location’ is in your theme’s wp_nav_menu arguments array should be passed to the uberMenu_direct function.

Example:

/* Replace this */
wp_nav_menu( array(
  'theme_location' => 'main', // "main" is the value you need in this case
  'container_id' => 'nav-menu'
));

/* with this */
if( function_exists( 'uberMenu_direct' ) ) uberMenu_direct( 'main' );

Alternatively, if you have UberMenu Easy Integration enabled in your control panel, you can use

if( function_exists( 'uberMenu_direct' ) ) uberMenu_direct( 'ubermenu' );

Recommended: If you are using a caching plugin, you should disable the Default to theme menu in IE6 setting in the UberMenu Control Panel > Theme Integration. You don’t want your caching plugin to cache a non-UberMenu version of the page.


For now, if you experience this issue and the above does not help, the recommended solution is to disable caching.