Filter wp_nav_menu()

I think I got the answer: function my_nav_menu( $args = array() ) { $echo = isset( $args[‘echo’] ) ? (bool)( $args[‘echo’] ) : true; $args[‘echo’] = false; add_filter( ‘wp_nav_menu_objects’ , ‘my_filter_nav_menu’ , 100 , 2 ); $menu = wp_nav_menu( $args ); remove_filter( ‘wp_nav_menu_objects’ , ‘my_filter_nav_menu’ , 100, 2 ); if( $echo ) echo $menu; else … Read more

Add Javascript to WordPress Menu

Good that it works. If it’s for a client or if you just want a cleaner code, you can do it as @Tom J Nowell suggested. Add a custom menu item, link it to nowhere or anywhere. Find out the menu item ID (every item has one), and then target that ID with jQuery. $(“#menu-item-num”).on(“click”, … Read more

How to Add to Each Menu Link with link text to data-attr?

Solution 1: Using customize walker I got some idea from add span class inside wp_nav_menu link anchor tag and made some changes for your requirements. 1. Add this code below to your functions.php first. class Nav_Walker_Nav_Menu extends Walker_Nav_Menu{ function start_el(&$output, $item, $depth, $args){ global $wp_query; $indent = ( $depth ) ? str_repeat( “\t”, $depth ) … Read more

Mega Menu Walker

If I understand the problem setup correctly, you could try to do the break and widget class counting within the wp_nav_menu_objects filter. Here’s an updated example, it’s rather expanded because of the extra debug part: add_filter( ‘wp_nav_menu_objects’, function( $items, $args ) { // Only apply this for the ‘primary’ menu: if( ‘primary’ !== $args->theme_location ) … Read more

WordPress Admin Bar Overlapping Twitter Bootstrap Navigation [closed]

How to prevent the WordPress admin bar from overlapping with your Twitter Bootstrap navigation bar. In response to: WordPress admin bar overlapping twitter bootstrap navigation Asked by: @TheWebs If you are using Twitter Bootstrap with WordPress and have an issue with the WordPress admin bar overlapping with your navigation bar, you’re probably pretty frustrated with … Read more

How to give paged links custom title?

Here’s a way to support pagination titles of the form: <!–nextpage(.*?)?–> in a simlar way as the core supports <!–more(.*?)?–>. Here’s an example: <!–nextpage Planets –> Let’s talk about the Planets <!–nextpage Mercury –> Exotic Mercury <!–nextpage Venus–> Beautiful Venus <!–nextpage Earth –> Our Blue Earth <!–nextpage Mars –> The Red Planet with the output … Read more

Split up wp_nav_menu with custom walker

Using a custom Walker, the start_el() method has access to $depth param: when it is 0 the elemnt is a top one, and we can use this info to maintain an internal counter. When the counter reach a limit, we can use DOMDocument to get from full HTML output just the last element added, wrap … Read more