Displaying Logged-In User Name and avatar in WordPress Menu

Question

I want show the avatar user and username with this code.

add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' );
function my_dynamic_menu_items( $menu_items ) {
    foreach ( $menu_items as $menu_item ) {
        if ( strpos($menu_item->title, '#profile_name#') !== false) {
                $menu_item->title =  str_replace("#profile_name#",  wp_get_current_user()->user_login, $menu_item->title);
        }
    }

    return $menu_items;
}

The username is work but i don’t known add avatar.

Can you help me please

0
, WartraxX 2 years 2020-01-04T08:38:48-05:00 0 Answers 83 views 0

Leave an answer

Browse
Browse