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
- How to add elements to an empty array in PHP?
- Adding first / last CSS classes to menus
- Mega Menu Walker
- start_lvl Ignored in Custom walker_nav_menu
- Displaying Logged-In User Name in WordPress Menu
- Hide main div if wp_nav_menu is empty
- Menu Items Disappearing
- Where to get information about array fields in $_REQUEST?
- Pass a PHP variable to another file
- wp_delete_auto_drafts() deletes links in menus
- How to store the_title() into a variable to reutrn the value, not just echo it
- Variables declared in header not available in other includes
- How do I make my function add variables/values to the $post object?
- Check if a menu is empty?
- 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 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
- Difference between “Walker_Nav_menu” and “walker”
- Add parent menu item in sub-menu in custom nav_walker
- How to find php variable of wordpress theme settings
- How to create a sub-page of sub-page?
- Add class to all meta boxes for a custom post type
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Vertical Menu for one page only
- Display specific main Sub Nav on Woocommerce product pages
- PHP drop down menu for my get_category child of
- Passing parameter from the current URL to redirect to another url
- Widget Logic – display on page and all child
- How limit the width of a fixed menu-bar on scroll?
- Undefined variable & issue with smof_data
- Beyond widget side menu editing, with the php page, custom template
- How to list categories by page id in wordpress
- Adding button to wordpress menu
- Where can I find the declaration of `$_wp_theme_features`?
- Child theme functions.php file change database entries
- Editing existing pre-created menus in PHP
- Two theme locations for two menus, but only one is showing up
- wp_nav_menu doesn’t work in a duplicate server
- How I can add div to menu?
- Custom Taxonomy Link Text Echo Name Not Slug
- wp_nav_menu prints children with parent name
- wp nav menu without label
- Contact form field in wordpress menu
- WP Admin Bar – Get current theme name as custom menu title
- Add extra markup to WP menus
- How to call a certain object/menubar in a PHP file
- Active class not working on custom menu link using add_menu_page
- how to add number value in front for variable [closed]
- Sidebar current menu item for parent
- Using ‘array’ method in wp_nav_menu causes it to disappear
- Remove all nav menu classes except those which begin with certain letters
- How to add a code for lastpostdate after/inside a specific menu link?
- Add the “.current-menu-item” class to tag?
- Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?
- How to get the count for each taxonomy term
- Difference in Get Variable Location
- WP_Nav Highlight Parent Issue
- WordPress adding in site URL to header links
- How to change the menu color
- Can’t remove menu items added by plugin
- Custom Links in Walker Class
- Submenu opened problem
- if is_home(), change class of menu-item-225 of wp_nav_menu
- Nav Menu Display
- Adding a unique class to wp_nav_menu
- Change order that the menu is generated with wp_list_pages
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- How do I modify the with wp_nav_menu()
- If I define a variable in header.php, how do I make it available to templates?
- Shortcode not passing variable to included file
- ACF allow zero as a value
- Make a permalink to the most recent blog post
- Can’t get options with $data[‘variable’]
- WordPress menu links with images & class selection
- PHP Use Declared array Variable inside already Declared Array
- Import and use a variable in additional settings of Contact Form 7 [closed]
- Open WordPress Page from selected option dropdown
- Inserting a shortcode into a genesis menu?
- Use ajax response in PHP function
- 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
- How to add different menu items on different menus?
- How can one use variables in a template or template part without polluting the global scope?
- Custom nav with bootstrap dropdown
- Nav menù doesn’t display selected pages
- How to make my scroll bar show under condition
- PHP Warning: Attempt to read property “id” on null
- Show a text in menu
- How to access admin menu labels and links on front-end?
- make my custom theme support polylang plugin
- How to get default variation ID (woocommerce)
- Can’t assign menu parent id or menu item breaks
- What is considered good practice for registering menu locations?
- Get check box values inside array for use in posting form data
- How to Customize the Admin Sidebar Menu in WordPress Multisite Network by changing the backend code of the wp-admin code files?
- How can I save the HTML output of a WP_Query function as a variable?