How to get the term id inside the start lvl method of category walker?
You can’t because you don’t have access to the element in that stage, but check this answer.
You can’t because you don’t have access to the element in that stage, but check this answer.
I found solution here Create template for parent pages: <?php /* Template Name: Redirect To First Child */ if ( have_posts() ) { while ( have_posts() ) { the_post(); $pagekids = get_pages( “child_of=” . $post->ID . “&sort_column=menu_order” ); $firstchild = $pagekids[0]; wp_redirect( get_permalink( $firstchild->ID ) ); } } ?>
The answer was that the theme location is primary_navigation with an underscore, not primary-navigation with a hyphen. I’m not sure why it seemed to work without the walker argument. Typical and along the lines of what it seemed like must be the solution. The obvious thing I wasn’t seeing because of feeling overwhelmed by an … Read more
You can access those classes like this: // where ‘Top’ is the menu name, slug or ID. But not menu location. $menu_items = wp_get_nav_menu_items( ‘Top’ ); foreach ( $menu_items as $menu_item ) { $menu_classes = $menu_item->classes; print_r( $menu_classes ); }
You can to pass class into function arguments: ‘menu_class’ (string) CSS class to use for the ul element which forms the menu. Default ‘menu’. So you can try this: <?php $args = array( ‘menu_class’ => ‘nav header-nav header-bottom-nav nav-center nav- uppercase’, ‘menu’ => ‘(your_menu_id)’ ); wp_nav_menu( $args ); ?> You can read about WordPress Menus. … Read more
how to split vertical menu into two columns using walker nav menu
You should check the $depth argument to make sure the search form only appears at a certain depth/level, e.g. if( 0 === $depth ) { … } I personally would place the search form outside the <ul> though as I don’t think it’s valid HTML. It would hurt your site’s accessibility. Alternatively, wrap it in … Read more
best and easy way to hide submenu is to use css .sub-menu { display: none !important; } Or you can use ‘depth’=>1 `wp_nav_menu( array( ‘menu_id’=>’nav’, ‘theme_location’=>’header-menu’ , ‘depth’ => 1) ); or create a function to set the ‘depth’=>1 for a perticular menu. place this code in your theme function.php add_filter( ‘wp_nav_menu_args’, ‘remove_my_header_dropdown’, 1, 1 … Read more
By default wp_nav_menu() outputs the navigation markup. If you want to store it or want to concatenate it with other string then you’d have to set the echo parameter to false (by default it’s true). $output .= ‘<ul class=”sub-menu”> ‘ . wp_nav_menu( array( ‘theme_location’ => ‘col_1’, ‘menu_id’ => ‘col_1’, ‘menu_class’ => ‘col_1’, ‘container’ => ”, … Read more
I Try to find how to collapse all cat by default in other word In that case, then try this script (replace the one you have now): <script> ( function ( $ ) { $( ‘li.has-children’, ‘#cat-drop-stack’ ).on( ‘click’, ‘> a span.caret-icon’, function ( e ) { e.preventDefault(); var self = $( this ), submenu … Read more