Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created February 23, 2012 14:58
Show Gist options
  • Save thomasgriffin/1893183 to your computer and use it in GitHub Desktop.
Save thomasgriffin/1893183 to your computer and use it in GitHub Desktop.
add_filter( 'wp_nav_menu_args', 'tgm_custom_nav_menu_args' );
function tgm_custom_nav_menu_args( $args ) {
$args['unique'] = $args['theme_location'];
return $args;
}
add_filter( 'wp_nav_menu_objects', 'tgm_filter_nav_menu', 10, 2 );
function tgm_filter_nav_menu( $objects, $args ) {
foreach ( $objects as $object ) {
if ( isset( $args->unique ) )
$object->url = add_query_arg( array( 'unique' => $args->unique, 'ref' => $args->theme_location ), $object->url );
else
$object->url = add_query_arg( 'ref', $args->theme_location, $object->url );
}
return $objects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment