Skip to main content
added 59 characters in body
Source Link
Johannes Pille
  • 11.1k
  • 3
  • 42
  • 53

iI have this filter:

function wpa_filter_nav_menu_objects( $items){
    global $count4footer;

    foreach( $items as $item ){

        $count = countPosts($item->ID);
        if($count!==false){
            $item->title = $item->title." ($count)";
            $count4footer[$item->ID]=$count;
        }
    }

    return $items;
}
add_filter( 'wp_nav_menu_objects', 'wpa_filter_nav_menu_objects' );

} add_filter( 'wp_nav_menu_objects', 'wpa_filter_nav_menu_objects' );

i I need to pass variable to the footer  , but is printing null null, i didI added global $count4footer; into the function , but no efect , how to run after filter , Thank youno effect.
How can I access this value later?

i have this filter

function wpa_filter_nav_menu_objects( $items){
global $count4footer;

foreach( $items as $item ){

    $count = countPosts($item->ID);
    if($count!==false){
        $item->title = $item->title." ($count)";
        $count4footer[$item->ID]=$count;
    }
}

return $items;

} add_filter( 'wp_nav_menu_objects', 'wpa_filter_nav_menu_objects' );

i need to pass variable to footer  , but is printing null , i did global $count4footer; in function , but no efect , how to run after filter , Thank you

I have this filter:

function wpa_filter_nav_menu_objects( $items){
    global $count4footer;

    foreach( $items as $item ){

        $count = countPosts($item->ID);
        if($count!==false){
            $item->title = $item->title." ($count)";
            $count4footer[$item->ID]=$count;
        }
    }

    return $items;
}
add_filter( 'wp_nav_menu_objects', 'wpa_filter_nav_menu_objects' );

I need to pass variable to the footer, but is printing null, I added global $count4footer; to the function , but to no effect.
How can I access this value later?

Source Link
mIRU
  • 101
  • 1

Passing variable from filter

i have this filter

function wpa_filter_nav_menu_objects( $items){
global $count4footer;

foreach( $items as $item ){

    $count = countPosts($item->ID);
    if($count!==false){
        $item->title = $item->title." ($count)";
        $count4footer[$item->ID]=$count;
    }
}

return $items;

} add_filter( 'wp_nav_menu_objects', 'wpa_filter_nav_menu_objects' );

i need to pass variable to footer , but is printing null , i did global $count4footer; in function , but no efect , how to run after filter , Thank you