You can use “get_avatar” function to display avatar in menu with user name. Please try code given below:
add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items', 10 );
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 .' '. get_avatar( wp_get_current_user()->user_email, 50), $menu_item->title);
}
}
return $menu_items;
}
Related Posts:
- Replace comment avatars and links at the same time
- Show custom default avatar instead of gravatar
- Modify previous and next text from pagination links
- Shortcode putting html such as
- Calling a method from functions.php on a click of a button
- How to redirect users to custom lostpassword page?
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- Can I write ‘RewriteCond’ using ‘functions.php’?
- How do I create comment-reply-button using element not
- How to add 2 posts under another post? Formatting should be intact
- WordPress menu deletes when trying to add a hook
- Overriding a theme redux file in child theme
- Validate a users email address when using gmail to register
- Get widget settings function?
- Using PHP to toggle stylesheet and header image, set in cookie
- Insert all post IDs in new database table
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- How do I publish only one page to production after making changes on staging?
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Using Multiple Submit buttons to trigger customised php functions
- How to get specific image in media library with php
- get current product name in functions.php
- Only Show Link If div Exists
- Change the WP Video Shortcode Output
- How to pick the default selected value in wordpress dropdown?
- Using WP-API and SSE not authenticating user ID
- Validate functions before inserting then into functions.php
- How to retrieve current wordpress profile page URL?
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- Exclude category
- Security for data obtained from the database
- How can I make an object available through the entire site?
- WordPress admin-ajax.php
- What exactly do this function declared into functions.php file of a WP theme?
- Display Data in Table from External Database in WP using Shortcodes
- How to check if a Customizer setting is set?
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Remove item in Checkout
- How to get current post category details inside “loop”?
- Co-Authors Plus: How do I get all authors with a query?
- Why i can’t get custom fields value or post ID via Ajax?
- How to reference PHP in Javascript
- Fallback image URL if no featured image exists via a shortcode function
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Deactivate a plugin on wp version
- Get the alt text of the image in a array
- making php value numeric
- the_post_thumbnail issues
- Make table disappear when fields are left blank?
- WP insert post Redirect after function has executed
- Unzip file in functions.php, and add it to cron
- Add Block Before Entry Title Using PHP
- How to assign page id with array in page_scheduled_event
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Dynamically populate parameter in Gravity Forms using PHP
- Store ajax data in PHP variable
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- How to Send Pingbacks for all Posts in WordPress?
- HTML comment cause issue in functions.php script root
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can i create a function tag in my plugin
- Including user data in “new user notification email”
- Reload page with a different shortcode when a user selects from a dropdown
- Refresh page after login with litespeed cache
- Return newly created category by code
- WordPress Ajax filter: Create two loops for different output styles?
- Woocommerce Add custom “Add to cart button” in single page with tags
- Hook into all password resets in WordPress and get password before hashing?
- How to call a function from functions.php with ajax?
- Set user status to absent on WordPress
- remove_action() not working in page template – Genesis
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Dropdown menu on custom menu
- Showing wordpress latest post thumbnails in slider with auto increment
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- My function echos only “array”
- Notify admin (by email) if post added with specific tag
- WordPress get_post_meta issue
- Woocommerce Price Text
- Limit Taxonomy Parents
- WordPress HTML Helper
- List sibling pages widget, exclude current page
- How to add button to top of theme customizer?
- ajax form function error
- Display custom meta box in my template file
- Send foreach $_post method to contact form 7 [closed]
- Simple Probléme in wordpress
- Options.php loop won’t show!
- Contact form with dynamic dropdown and filter
- Critical Error customiser
- Why a class property becomes empty?
- Hide category by tag
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Background Tasks in a WP Cronjob?