Skip to content

Instantly share code, notes, and snippets.

@alessandrotesoro
Created March 6, 2014 13:47
Show Gist options
  • Save alessandrotesoro/9390054 to your computer and use it in GitHub Desktop.
Save alessandrotesoro/9390054 to your computer and use it in GitHub Desktop.
WordPress programmatically filter menu items given a location
/**
* Filter Menu Items
*/
function tdp_filter_menu_items( $items, $args ) {
if($args->theme_location == 'primary_menu')
{
$items .= '<li class="primary-menu-secondary-item"><a href="#">Menu Item</a></li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'tdp_filter_menu_items', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment