• Hello again ??

    Is it possible to get my custom meta key {company_name} in the menu bar?

    {first_name} works for only.

    best,
    Remy

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @remykonings33

    Please try following code snippets:

    add_filter( 'wp_nav_menu_objects', function( $sorted_menu_items, $args ){
    
        if ( empty( $sorted_menu_items ) ) {
            return $sorted_menu_items;
        }
    
        foreach ( $sorted_menu_items as $menu_item ) {
            
            if ( is_user_logged_in()  && $menu_item->title  == '{company_name}') {
                $menu_item->title = get_user_meta(get_current_user_id(),'company_name',true );
            }
           
        }
    
        return $sorted_menu_items;
    
    }, 9999, 2 );

    Please replace company_name with your own metakey.

    Thread Starter remykonings33

    (@remykonings33)

    Thank you Aswin,
    That works great!
    Appreciate the help ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Meta key in menu bar’ is closed to new replies.