You should never need a plugin to insert raw PHP code somewhere. There are always side effects you cannot see or fix easily.
Filter wp_nav_menu_objects
instead, and add the parameter here to the URLs.
if ( ! empty ( $_GET['partenaire'] ) )
add_filter( 'wp_nav_menu_objects', 'wpse_82194_add_param' );
/**
* Add a parameter to item URLs.
*
* @wp-hook wp_nav_menu_objects
* @param array $items
* @return array
*/
function wpse_82194_add_param( $items )
{
$out = array ();
foreach ( $items as $item )
{
$item->url = add_query_arg( 'partenaire', $_GET['partenaire'], $item->url );
$out[] = $item;
}
return $items;
}
Related Posts:
- Pulling a variable into the wp_nav_menu function
- Mega Menu Walker
- Displaying Logged-In User Name in WordPress Menu
- Pass a PHP variable to another file
- how to put the logo in the center of other items in the navigation bar
- renaming an admin menu item with decimal array index number
- How can I hook into and edit the text of a wp_nav_menu tag?
- How to show only parents subpages of current page item in vertical menu?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- removing tags from wp_list_pages() using PHP
- How can I add a class to a single menu item?
- Replacing the NavWalker dropdown element
- How to add specific menu on a specific page or pages
- WordPress menu deletes when trying to add a hook
- Logout and redirect using the WP Menu
- Remove all nav menu classes ( but keep useful ones… )
- Second Navigation inside header
- selected menu item
- Locating Global Variables
- Pass PHP variable to JavaScript without inline JS
- Count the number of times the search form template gets included on a page
- Putting PHP variables into javascript [duplicate]
- How to display conditional-content if wp_nav_menu( $args ) retruns something
- Can’t extend some core classes
- Show comments menu in dashboard only if the site has comment
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Using a variable in is_page(array())
- Count top level menu items
- Multiple WordPress Menus that will only display all pages
- Menu — How to add “current-menu-grand-ancestor” css class
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to put a variable in a instance in the widget
- get_term_link() returns correct – But illogical error-messages disturb
- Menu Limitations
- Pass variable from one function to another
- Remove metabox from WordPress menu editor page?
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- How to modify a global variable in a function and use it on another function?
- Secondary navigation menu on one page
- Remove class in nav_menu_link_attibutes filter
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Custom Menus: dynamic highlighting problem with custom home link
- Add item to top of menu using a filter in functions.php
- Adding PHP in the menu
- How to style one item from main navigation?
- How to pass a PHP $_GET variable and fetch/output it?
- Creating WordPress Shortcode with Variable
- persist a variable set in header.php all the way down to footer.php
- Automatically add images to a menu
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- javascript variable to wordpress php variable
- Menu Custom Data Attributes
- Notice: Trying to get property of non-object
- How to reference PHP in Javascript
- How to modify mobile nav menu text in theme
- How can I use custom menus with a Bootstrap WordPress theme?
- echo var into wp_query
- Nav menu from plugin to theme
- Adding Additional Variables on Menus Page
- Custom navigation menu with awsAccordion
- Why in this WordPress theme I can’t see the Main Menu?
- wp nav menu: show submenu below li item
- Dynamic Menu drops pages?
- Class for Selected Menu using wp_nav_menu
- Styling an “active” link outside of WordPress default menu
- How to create Loop code for Menu using WordPress?
- Hard-coding a shortcode as the last menu item in primary navigation?
- How to send a php var to jQuery Ajax call with two different file
- Featured image in menu wordpres
- How to set Nav as a default menu in wordpress
- WordPress How do I pass a variable from one add_action to another?
- Best way to use variables in multiple functions?
- How do I fix Undefined variable using $_POST in function?
- Get Child of Child Pages in custom Menu
- PHP warning with code for nav menu walker [duplicate]
- Add element after navigation element title don’t works like I expect
- How to disable sub menu items from being created?
- String replace for Login/Logout concatenation problem in menu
- Bring Font Awesome icons inside menu A tags
- How to create a sub-page of sub-page?
- Display specific main Sub Nav on Woocommerce product pages
- PHP drop down menu for my get_category child of
- Adding button to wordpress menu
- Editing existing pre-created menus in PHP
- Custom Taxonomy Link Text Echo Name Not Slug
- wp_nav_menu prints children with parent name
- WP Admin Bar – Get current theme name as custom menu title
- Active class not working on custom menu link using add_menu_page
- how to add number value in front for variable [closed]
- Difference in Get Variable Location
- Custom Links in Walker Class
- Submenu opened problem
- WordPress menu links with images & class selection
- Import and use a variable in additional settings of Contact Form 7 [closed]
- Open WordPress Page from selected option dropdown
- WP query with variables gives no result for specific user
- Remove Unused Menu Locations
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0