Sometimes, a theme or plugin will use a filter to strip out the standard WordPress menu item classes like menu-item
(note that these classes are all prefixed with ubermenu
in UberMenu 3). When these are removed, UberMenu’s styles, which rely on these classes, cannot be applied. Themes and plugins should never remove core functionality.
Here is more information on Theme Interference
Identifying the problem
The easiest way to spot this is to look at the UberMenu source and see if the standard classes like ubermenu-item
are present on the li
s. If they are missing, they have been stripped.
Most of the time, this issue occurs when a theme or plugin adds a filter to the nav_menu_css_class
hook. Here’s an example:
function remove_menu_styles($classes, $item) { //some code return $classes; } add_filter('nav_menu_css_class', 'remove_menu_styles', 10, 2);
This can also occur if a theme manipulates the output of the wp_nav_menu
function, via the `wp_nav_menu
` filter or directly in the theme templates, replacing string with str_replace or preg_replace. This is very bad practice.
Note that if the class names appear in the page source, but not in the DevTools, it indicates that they have been removed via javascript (this is very uncommon).
The Solution
UberMenu 3 Setting
In UberMenu 3, there is a setting in the Control Panel > General Settings > Miscellaneous > Disable Menu Item Class Filtering.
If the classes are being filtered via the nav_menu_css_class
filter, this should resolve it.
Manually in UberMenu 2
Once you’ve located the filter, copy the line that starts with add_filter(
into your child theme’s functions.php. Then change add_filter to remove_filter
remove_filter('nav_menu_css_class', 'remove_menu_styles', 10, 2);
Ensure that this line of code runs AFTER the line from the theme/plugin. You may need to attach it to a different WordPress action.
preg_replace or str_replace
If the theme is running string replacement on the menu output, it is best that you just replace the theme’s menu system with Manual Integration (or Easy Integration in UberMenu 2).
Javascript
If your theme is removing the classes via javascript, this would need to be resolved either by removing that javascript, or altering the menu markup to prevent that JS from applying to UberMenu.