You can target the location like this:
function wpa_filter_nav_menu_objects( $items, $args ){
if( $args->theme_location === 'primary' ){
foreach( $items as $item ){
if( strtolower( $item->title ) === 'sample page' ){
$item->title = $item->title . '(10)';
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_objects', 'wpa_filter_nav_menu_objects', 10, 2 );
You can also try $args->menu_id
if you use that input parameter.
Related Posts:
- Is there an easy way to replace a custom menu link with a page or post?
- Why do Custom Nav Menus generate so many classes on list items? Can I manage this somehow?
- Custom search filter causes menu and query_posts problems
- Add separator to admin submenu
- register_nav_menus() won’t register menus
- How do I add nested categories to drop-down menu in twenty-eleven?
- Add custom page link with anchor
- How to include the ‘current-menu-ancestor’ class on a custom post type menu in WordPress?
- How to add menu to Dashboard that can be viewed by all users
- HTML Bootstrap navigation menu to WordPress menu using wp_nav_menu
- List children of second level sub page
- Show top-level parent with submenu menu walker
- Add section to custom menu panel
- Adding a class (arrows) to main menu links that have children?
- How to change menu according to the language?
- Adding menu items dynamically using wp_nav_menu_objects
- BuddyPress – How to add logout in nav menu
- Highlight the “Home” / “Blog” button while on main page
- Navigation (wp_nav_menu) refuses to nest within parent element
- how to add Custom menu item like User name in Header Menu only
- Display three different levels of navigation from wp_nav_menu separately?
- Wp_Nav_Menu – Identify the last menu item
- Add custom menu item metabox in Navigation Settings
- Menus – Open items in new tab/window?
- Image as a link using wp_nav_menu()
- Highlight another nav item
- Custom Menu url is Empty
- Get category ID from nav menu
- How to make link to different categories that in them selves loads different menus?
- Menus don’t appear in admin area / WordPress Multisite
- Programmatically add existing pages and subpages to Appearance Menu
- Highlight current post ancestor parent menu items
- Ad custom admin page like WordPress customizer [closed]
- Appearance Menus Screen – menu item drop down menu not functioning
- Weird behaviour on Edit Menus screen
- Remove nav menu item by script
- Make a navigation menu in the same post [duplicate]
- Custom Menu Broken WP 3.8.1 Update
- How to actually make menu walker alive on admin interface?
- Get menus created with menu editor?
- How to I know the class or ID of my theme?
- Highlight parent if item from submenu is active
- How to exclude pages in the menu without pageID?
- Missunderstanding of WordPress menus
- How to add schema.org SiteNavigationElement and property URL to navbar?
- changing host.. data loss
- Theme Location empty
- Replace the slug of parent pages with # [closed]
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Wrapping menu’s top-level link and sub-menus in div
- Page appears after de registering from menu
- Menu on mobile version doesn’t collapse after choosing menu item [closed]
- If current menu item is child or parent with child?
- Is it possible to dynamically register menus?
- Dynamic menu wp_list_pages displaying only current branch including: current page, his siblings and its childs
- Parent Page > Child Page Menu
- Opening Menu link in another tab
- How to add class to anchor using wp_nav_menu
- Page header menu links change
- displaying meta key value with wp_page_menu
- WordPress Menus – How to add inline styles to UL menus
- Is it possible to link to the same page from wordpress page menu?
- Remove current-menu-item for a specific link
- How do I add 3rd level of dropdowns to wp_nav_menu array?
- How to remove empty menu space when creating admin page without menu title using add_submenu_page
- How to work with a custom theme that someone else created before me? (details below)
- changin the url (permalink as it goes these days) on one specific menu layer
- Custom menu items in admin
- Using Anchor Link In Nav Menu
- WordPress database issues – menu not saving correctly, media thumbnails not showing
- WordPress Accessible Keyboard Menus
- How do I create a new directory to hold the assets for a new menu item?
- How to set active class to the menu of any page coming from a single.php template
- Parent link need to go first child submenu
- mysterious menu
- Importing large product categories into wordpress menu
- Different HTML markup for similar menus
- Menu for specific user
- Add newsletter signup element to navigation bar
- All custom links suddenly lack href attributes
- wp_nav_menu custom Page class
- Why does appear? I’m trying to remove a generic link called navigation on my main menu
- WordPress – Apperance > Menu
- How to stop showing menu in static home page
- How do I fix the URL used in the WordPress admin menu for customize.php
- Menu id in nav menu ignored
- Bootstrap 3 and WordPress menu navigation menu highlighting
- How do I add a link to the menu that has a charector (?) in it?
- Problem with custom menus
- Add class to current category menu item
- WordPress wp get nav menu items does not deliver external link
- wp_nav_menu changed to wp_page_menu
- how to assign an ID to a wordpress menu
- How to load css file in my menu in wordpress
- Site pages show the page title under navigation bar
- Keeping my Sub Menu open when hovering on its list items
- Navigation menu, remove item from desktop
- Jquery dropdown menus working locally, but not in WordPress [duplicate]
- Wrapping my ‘s with
- How to replicate a mobile menu from a site to a wordpress site [closed]