Appending Custom Query Parameters to wp_nav_menu

I need to append custom query parameters on to every link inside a wp_nav_menu call.

So after every href in the menu append either ?var1=apple&var2=orange’ or ‘&var1=apple&var2=orange’.

Read More

How can I do this?

wp_nav_menu( array( 'container' => 'nav', 'container_class' => 'nav-menu',
 'menu_class' => 'main-menu main-nav clrf dropdown', 
'theme_location' => 'header', 'enable_bp_links' => true, 'show_home' => true ) );

Related posts

Leave a Reply

1 comment

  1. The default nav menu code doesn’t have this option. What you CAN do is create a small plugin that hooks into the nav menu before it gets displayed and use an XML transform to add this to every link.

    I’ve done this before and it worked successfully but I don’t have the code nearby right now. All I can do is promise that this works. When I next get a chance I’ll try to remember to post it.