How to add post count to wp_nav_menu?

Basically the easiest thing should be a callback to the start_el() method of the Walker class. // From core: apply_filters( ‘walker_nav_menu_start_el’, $item_output, $item, $depth, $args ); Just grab the data (whatever the actual data is and from wherever it comes) and append it. add_action( ‘walker_nav_menu_start_el’, ‘wpse_10042_nav_menu_post_count’, 10, 4 ); function wpse_10042_nav_menu_post_count( $output, $item, $depth, $args … Read more

How show sub menu only using wp_nav_menu()

I’ve made a free plugin which solves this problem! https://wordpress.org/plugins/wp-nav-menu-extended/ This plugin extends the native wp_nav_menu function and adds additional options: level : (integer) (required for this plugin to work) The level of the navigation menu to show. If no child_of parameter is passed, it shows all the items of this level child_of : (string|integer) … Read more

Create a formatted table-like menu

I think your question is a perfect example for the XY Problem. In WordPress you do not create such a menu in a post editor. You use a menu. Once you start thinking about your problem from this point, everything is easy. 🙂 First register a custom navigation menu for this list in your theme’s … Read more

Determine if a navigation item has children

You can filter wp_nav_menu_objects and add the classes in one rush. You don’t even need a custom walker for that. add_filter( ‘wp_nav_menu_objects’, ‘add_has_children_to_nav_items’ ); function add_has_children_to_nav_items( $items ) { $parents = wp_list_pluck( $items, ‘menu_item_parent’); foreach ( $items as $item ) in_array( $item->ID, $parents ) && $item->classes[] = ‘has-children’; return $items; } The class has-children will … Read more

How to set limit only on top levels of wp_nav_menu?

According to the codex, you just need to use depthparameter to display only top-level pages : <?php wp_nav_menu( array( ‘location’ => ‘your_location’, ‘depth’ => 1 ) ); ?> For more reference see this. You could also fix both of your problem by using [wp_get_nav_menu_items][2] and then using a custom loop to parse only first and … Read more

How to add active class on current menu item page?

You could add conditional classes for each in your child theme functions file: Here’s one example you can modify to suit your own needs. add_filter(‘nav_menu_css_class’ , ‘wpsites_nav_class’ , 10 , 2); function wpsites_nav_class($classes, $item){ if( is_archive() && $item->title == “Products”){ $classes[] = “products-class”; } return $classes; Source http://codex.wordpress.org/Function_Reference/wp_nav_menu#Adding_Conditional_Classes_to_Menu_Items You can then style your nav menu … Read more

How to custom output wp_nav_menu()

You will have to use a custom Walker for your menu. Here is the page in the codex that explains it: https://codex.wordpress.org/Class_Reference/Walker and here: https://developer.wordpress.org/reference/classes/walker_nav_menu/ Hope that helps.