wp_nav_menu treats menu_class differently for fallback
|Reported by:||Nonchalant||Owned by:|
I've found references to this issue, but no actual solution or prior ticket. Issue:
When using wp_nav_menu, the output manner of menu_class is different depending if a fallback is being used or not.
$wp_nav_header = array( 'theme_location' => 'primaryheader', 'menu' => '', 'container' => false, 'container_class' => '', 'container_id' => '', 'menu_class' => 'sf-menu', 'menu_id' => '', 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0,); wp_nav_menu( $wp_nav_header);
Output without Fallback (Correct output):
<ul id="menu-default" class="sf-menu"><li...
Output with Fallback (Incorrect output):
So despite setting 'sf-menu' in menu_class, it creates a container (which I had explicitly disabled). It also does not populate the unordered list with the mentioned class.
Change History (6)
- Keywords close added; needs-testing removed
- Milestone changed from Awaiting Review to Future Release
comment:2 in reply to: ↑ 1 @Nonchalant — 5 years ago
- Resolution set to fixed
- Status changed from new to closed
- Keywords close removed
- Resolution fixed deleted
- Status changed from closed to reopened