How to remove dropdown from wp_nav_menu

We can use depth parameter of wp_nav_menu to set how many levels menu walker traverses. wp_nav_menu( array( ‘menu_id’=>’nav’, ‘theme_location’=>’header-menu’ , ‘depth’ => 1) ); You can create a child theme so that updates won’t override during updates. Create child theme and copy code from header.php of parent theme then replace the code wp_nav_menu( array( ‘menu_id’=>’nav’, … Read more

Displaying menu based on login status

Ok, there are some pretty obvious differences between the original and your code, like: the use of a walker this is most certainly needed for the fancy styling the lost and empty menu_id parameter depending on the according CSS this might be needed too the use of the menu parameter ok, to switch the menu … Read more

How to add category post count in main navigation menu [closed]

This can be achieved many ways. But, the below method is most prominent to me. add_filter(‘the_title’, ‘wpse165333_the_title’, 10, 2); function wpse165333_the_title($title, $post_ID) { if( ‘nav_menu_item’ == get_post_type($post_ID) ) { if( ‘taxonomy’ == get_post_meta($post_ID, ‘_menu_item_type’, true) && ‘category’ == get_post_meta($post_ID, ‘_menu_item_object’, true) ) { $category = get_category( get_post_meta($post_ID, ‘_menu_item_object_id’, true) ); $title .= sprintf(‘ (%d)’, $category->count); … Read more

How to remove UL class in wp_nav_menu?

To remove ul class from wp_nav_menu, you will have to define menu_class to false. Default wp_nav_menu ul menu class is menu. <?php wp_nav_menu( array( ‘container’ => false, ‘items_wrap’ => ‘<ul>%3$s</ul>’, ‘theme_location’ => ‘mainmenu’ ) ); ?> I added mainmenu as theme_location. You should change it to your theme location. Read full list of args on … Read more

Two menus show up

You have two calls to wp_nav_menu function <?php if( has_nav_menu( ‘primary-menu’ ) ) { wp_nav_menu( $menuParameters = array( ‘theme_location’ => ‘primary-menu’, ‘container’ => ”, ‘container_class’ => false, ‘container_id’ => false, ‘menu’ => ‘Primary’, ‘menu_id’ => ‘test’, ‘menu_class’ => ‘nav navbar-nav navbar-right’, ‘echo’ => true, ‘fallback_cb’ => ‘wp_page_menu’, ‘before’ => ”, ‘after’ => ”, ‘link_before’ => … Read more

How to override menu markup?

OK got it. For anyone who needs to do this , it is best you extend Walker_Nav_Menu class if you just need to add things to existing wp menu structure. Otherwise if you are extending Walker class you kinda have to rebuild the menu completely. Include this class class Walker_Extend_Menu extends Walker_Nav_Menu { // Tell … Read more

Adding PHP in the menu

Add to your functions file and use wp_nav_menu_items add_filter(‘wp_nav_menu_items’,’wpsites_add_avatar_to_nav’, 10, 2); function wpsites_add_avatar_to_nav( $items, $args ) { if( $args->theme_location == ‘primary’ ) return $items; $dude = get_avatar( get_current_user_id(), 48 ); if (is_user_logged_in()) : echo'<li class=”your-custom-class right”>’ . $dude . ‘</li>’; endif; return $items; } Might need to use output buffering. Some work is required on … Read more

Child Theme header1.php file not overwriting parent theme’s header1.php file

That edit explains it. Alphabet is poorly written. Its use of php’s include rather than WordPress’s own include functions like get_header and get_template_part is breaking the parent/child hierarchy. You could probably make a copy of the file header.php and change those includes, as long as the file calling in header.php does it correctly! As long … Read more