php - Display logged-in User Avatar in Wordpress Nav Menu -
i'm using function display logged-in user name in wordpress navigation menu , display logged-in user avatar in menu couldn't find way this. i'm asking :) here function i'm using name:
function my_dynamic_menu_items( $menu_items ) { foreach ( $menu_items $menu_item ) { if ( '#current-username#' == $menu_item->title ) { global $shortcode_tags; if ( isset( $shortcode_tags['current-username'] ) ) { // or do_shortcode(), if must. $menu_item->title = call_user_func( $shortcode_tags['current-username'] ); } } } return $menu_items; } add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' );
i have code in functions.php , call #current-username# in menu item, there way customise code output avatar? help.
try : echo get_avatar( $id_or_email, $size, $default, $alt );
Comments
Post a Comment