wp_nav_menu_items filter :: custom menus fall outside ul class

The problem are these lines: $items_icon = get_template_part( ‘templates/topbar’, ‘rolecart’ ); $items_icon = get_template_part( ‘templates/topbar’, ‘roledashboard’ ); where you expect get_template_part() to return the output, but it doesn’t, because it’s basically a wrapper for require() and require_once() calls. This means the template parts are not part of the returned filter value. I agree that the … Read more

Blog Posts in Custom Menu

I am little bit unsure, if this could really be an answer 🙂 But I think, you can simply create categories – Cooking, Beauty, Style. Assign those categories to respective posts. Then add these categories as menus. Now, when user clicks on any of the menu, he will see posts belonging to the respective category. … Read more

Fragment URL in navigation item without a custom link

You can modify the href attribute of specific menu items when the menu is generated. function wpd_convert_menu_items_to_hash( $atts, $item, $args ) { if( $somecondition ){ $atts[‘href’] = ‘#’; } return $atts; } add_filter( ‘nav_menu_link_attributes’, ‘wpd_convert_menu_items_to_hash’, 10, 3 ); In this example, $somecondition is whatever way you’re identifying these menu items. $item gives you access to … Read more

Add dynamic Sitemap to footer

You should call wp_nav_menu() in your footer.php template. It’s used as following : <?php wp_nav_menu( array(‘theme_location’=>’footer’) ); ?> The theme_location parameters refers to the checkboxes below the menu editor (Theme location). If your theme doesn’t have enough theme_location, you can add some by adding function register_html5_menu(){ register_nav_menus(array( ‘footer-1’ => __(‘Footer Menu 1’, ‘theme_translation_domain’), )); } … Read more

Hide sub menus sometimes

Try using the following code. .current-menu-ancestor > ul { display:block; } The class current-menu-ancestor appears if the current item is a parent of a current page item.

add span class and i tag inside wp_nav_menu link anchor tag

You can use the wp_nav_menu() arguments like so: wp_nav_menu( array( ‘menu’ => ‘Whatever Your Menu Name Is’, ‘link_before’ => ‘<span class=”main-nav__item-icon-wrapper”><i class=”main-nav__item-icon icon-home”></i></span><span class=”main-nav__item-content”>’, ‘link_after’ => ‘</span>’ ) ); link_before and *_after will add anything before/after the text inside the link where just the normal argument before and after will add anything before/after the entire … Read more