The easiest way to do that would be to inline some CSS in your php template. then you could replace that hardcoded image URL with the users avatar like background-image: url("' . echo $avatarURL . ");
You will definitely need to fix your snippet to get the avatar as well though. currently you’re returning the user ID and then trying to grab the avatar. anything after a return statement is unreachable code.
function get_current_user_avatar_url() {
if ( ! function_exists( 'get_current_user_id' ) ) {
return false;
}
$user = get_current_user_id();
return get_avatar_url($user);
}
then define $avatarURL
like $avatarURL = get_current_user_avatar_url();
Otherwise you’re getting into writing a custom nav walker, which is much more complicated.
Related Posts:
- WordPress default menu in database
- How is custom menu hierarchy output handled?
- Where would I find Custom menu attributes in the database?
- WordPress default menu in database
- cross-site custom menu
- Where is the order of a menu saved in the database
- is MariaDB error related to Automatically add new top-level pages
- WordPress database issues – menu not saving correctly, media thumbnails not showing
- Is there any way to recover deleted menu from database sql backup
- How to add drop down sub menu from database fields in the particular menu slug
- Database structure Menu Item
- Get_avatar filter hook not displaying custom avatar image on frontend
- Displaying a Custom Avatar in WP Bootstrap Navwalker Menus in WordPress
- wp_nav_menu: show menu only if one exists, otherwise show nothing
- Making breadcrumb with wp_nav_menu
- Renaming a WordPress Admin Menu
- Deleted pages are NOT removed from custom menus?
- How to add active class on current menu item page?
- Add Page ID class to nav menu items
- Way to bulk delete menu items in new 3.x Appearance > Menus system?
- WordPress nav_menu_link_attributes Not Working
- menu entries are lost
- Nav Menu and display post count
- Wrap description and sub menu in a wrapper
- Navigation menu with children shown only for current page
- Change menu items URL
- How to get the post name (slug) from the item ID when traversing the navbar?
- Why is ‘nav_menu_item_args’ filter’s $item argument empty?
- how to get nav menu list through menu name in wordpress
- wp_nav_menu – show children of current menu item only?
- How can I detect whether a BuddyPress page is active from within my theme?
- $variable (counter) inside wp nav menu
- Adding Custom “Current Menu Item” class to navigation?
- How can I add divs or change li in the submenu of the menu_nav
- How to create a Menu based a username
- How to add php to custom link in the nav menu? [closed]
- Did upgrading from 3.3 to 3.3.1 introduce breaking changes in the menu navigation?
- WordPress menu permalink redirects to wrong page
- HTML to WordPress Menu convert
- Remove current class from sub menu items
- How to change menu URLs to hashes?
- How do I render a navigation menu like my theme does?
- WordPress Menu Prepends URL To My Anchors
- How to handle many different menus?
- Check if menu_item has children or has parent
- Why is wordpress forcing https link generation?
- pull non-wp site into content area of wordpress -or- pull wp header into non wp site?
- How to remove the HOME menu item
- Adding menu items?
- How to get rid of the home link in nav menu?
- How to truncate menu label in wordpress?
- display menu as table layout
- How to change the location of the menu
- How can I make a menu link visible only to admins (without plugins)?
- magic “MENU” button under Twenty Twelve theme
- Remove first separator in wp_nav_menu
- change hover color of specific menu link [closed]
- How can I make a WordPress sub-menu with a top-level that isn’t clickable?
- WordPress classes removed when using custom walker
- Get parents child pages
- Show subpages of a category in a custom menu
- how to add home icon instead of text in wordpress menu
- How to add a menu that belongs to parent blog to all child-blogs?
- How to create this kind of sub-menu in new line?
- How to use wp_list_pages on a grandparent page
- How to add social buttons like facebook and twitter in the footer of a theme?
- Dropdown primary navigation menu not working
- Understanding with this WordPress code
- Link after WordPress
- When created sub-directory, can we create a new navbar?
- How to add an archive page to WordPress menus (nav_menu)?
- Misleading behaviour on Menu & Theme location
- Add category label for appearance > menus items
- Custom items for Menus
- Menu flickering with each refresh on Google Chrome [closed]
- Remove Double Menu in Mobile View and Have one Menu Only
- calling JS to custom menu design
- WP pages content is missing in frontend
- How i can get current menu id with multiple occurrence
- How to get rid of the bottom line in the navigation menu via CSS file?
- Active menu item state on all menu items
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- Installing compact search in the main menu?
- Backend – Categories and Menus conflicts
- Having an issue with wp_nav_menu displaying custom navigation
- Menu administration, how to allow special charachters
- How to avoid website url appending problem in wp site?
- Create custom page and custom menu
- Get first menu item of custom menu
- Bought custom navigation menu from codecanyon, how to change feature.php?
- Custom menu linking to page not found
- How to insert date in topNav
- Somehow lost my MENU from my home page- help!
- How to completely remove the top section with the menu?
- How To Conditionally Change Menu In Same Theme Location
- How to display a submenu as a popup when clicking a button?
- Not even able to Log in [closed]
- how can i get the page_ID in nav li [closed]
- How do i add logo in wordpress studiopress (glam theme)?
- How to replicate a mobile menu from a site to a wordpress site [closed]