Count Level 1 Childs for Custom Nav Walker WordPress

I’m trying to make my logic like this: calling below code inside function start_el( &$output, $item, $depth, $args ) { $this->sub_items = 0; // declared variable as private $sub_items = 0 above inside class if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] … Read more

Check in walker if current page is descendant

It seems to me, you are trying to get the ancestors by the actual post, while you most likely should get the ancestors according to the menu item. Why? Because setting up a hierarchy in the menu does not change the actual post, especially the post_parent property won’t be changed – in short: (other) post … Read more

Creating custom Menu for custom theme

You can remove the container and ul tag like this: <?php wp_nav_menu( array( ‘container’ => ”, ‘items_wrap’ => ‘%3$s’ ) ); ?> Now you can see an architecture like this: <li> <a href=”#”>item</a> </li> And i think you could adjust your stylesheet to adapt “li” tag. Hope it helps.