WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I search in Internet but i didn't find a good documented way how to add to item from menu a number , my current menu is like

Item3 ,

I'm calculating with WP_Query how many post for category i have , and within function to update a specific menu item like :


Thank you a LOT ! :)

i finded a solution , but i don't know how to filter by specific menu , location

function wpa_filter_nav_menu_objects( $items){

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' );

menu i'm creating in admin panel , from Apperance > Menus

Thank you again !

share|improve this question
Can you add more detail to your question? – Jake Lisby Jul 5 '13 at 21:34
In order to get valuable help you have to provide us with your current code. There are multiple ways to generate a list/menu... – tfrommen Jul 5 '13 at 21:52

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.

share|improve this answer
sorry but $args , i tried but is not working , thank you for help !!! – mIRU Jul 9 '13 at 10:29
ok, but this worked on my install, how do you call wp_nav_menu and what is the theme location? – birgire Jul 9 '13 at 11:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.