Hi,
I have Pro and I’m trying to dynamically change a menu item but Pro ignores the filter “nav_menu_item_title”. Why?
The code I’m using is this:
// Woocommerce login/logout
/* Simpler version - Not checking the theme location */
add_filter( 'nav_menu_item_title', 'custom_nav_menu_item_title', 10, 3 );
function custom_nav_menu_item_title( $title, $item, $args ) {
//Menu item should be set with the text you want to use for "logged out" users
//Logged in?
if ( is_user_logged_in() ) {
//Menu location and page to change
$id_page = get_option( 'woocommerce_myaccount_page_id' ); //Or the page ID if it's not a WooCommerce install
//Is it the correct page?
if ( isset( $item->object_id ) && intval( $item->object_id ) == intval( $id_page ) ) {
//Get the current user
//$user = wp_get_current_user();
//$title = 'Hello '.$user->display_name; //Or any other "logged in" text
$title = 'Fazer Logout';
}
}
return $title;
}