• Am creating a site whereby am enabling users to upload their own avatars using One User Avatar plugin. The upload functionality works fine.

    Since my menus are created dynamically using Wp Custom Navwalker. Am using a filter called wp_nav_menu_objects to filter the menu of a logged in user and display the avatar beside the username eg Welcome [avatar image] John Doe ,

    The problem is that instead of the avatar showing, what shows is the code . Below is the filter hook am using:

    function add_avatar( $menu_items ) {
    
        foreach ( $menu_items as $menu_item ) {
            if ( strpos($menu_item->title, 'Welcome') !== false) {
    		$menu_item->title =  'Welcome' . ' ' . get_wp_user_avatar( get_the_author_meta( 'ID' ), 'medium' ) . 'John Doe';
            }
        }
        return $menu_items;
    }
    add_filter( 'wp_nav_menu_objects', 'add_avatar', 10 );

    This is what displays on the frontend

    It shows the image url instead of the actual avatar. Please assist

  • The topic ‘USING wp_nav_menu_objects Filter hook to add an avatar created using One User Av’ is closed to new replies.