The function get_avatar
‘s 3rd argument is the default image, which you can also pass a function’s return value to, so wherever you run get_avatar
in your theme you can set a function that changes the default avatar as a 3rd argument.
get_avatar( get_the_author_meta( 'user_email' ), 64, 'http://example.com/path/to/image.jpg' );
Or, with a function’s return value as third argument:
get_avatar( get_the_author_meta( 'user_email' ), 64, figure_out_new_default_image() );
This IMO is the best place to pass the default image information to, since the $avatar_defaults
is for setting up a singular image that can be configured in Settings > Discussion of wp-admin.
Related Posts:
- WordPress and event-driven programming – what is it about?
- Cleaning up WordPress to improve performance?
- Include a external PHP file into a WordPress Custom Template
- List of all theme customizer control types?
- Show the most popular post per week
- Add a class to links in the visual editor (how to get old dialog back)
- Remove option to allow trackbacks/pingbacks from post page options
- How to remove hardcoded characters from playlists?
- Creating custom Woocommerce attribute taxonomies from a plugin
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- Load post content into iframe
- wp_customize_image_control default value
- Limit the Excerpt field in WP-Admin in words
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
- Overriding a theme redux file in child theme
- Widgets not showing in my custom theme
- How to display custom field on homepage
- How to get 2 or multiple custom post types in wordpress functions.php
- Creating bulk posts with Youtube videos
- Change the site tagline (or similar) based on current page
- Customizer: Output default value in Customizer CSS
- How to add just one specific page to widget without plugin?
- create a select input with menus created on a custom options page
- Taxonomy linked to pages
- Converting HTML Template to WordPress Theme
- Can I install/embed WordPress on a ‘single page’?
- How to pick the default selected value in wordpress dropdown?
- WordPress admin pointers tour bug?
- Customize position of social icons in upme plugin [closed]
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Media Upload , file name changed automatically
- Replace shortcode in substring
- Custom posts in different columns style
- need help with existing code showing subpages
- How do I add a custom css to all posts without affecting homepage css? [closed]
- What exactly do this function declared into functions.php file of a WP theme?
- Buddypress update user avatar image via REST
- Add data-id attribute to child page links
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- customize wordpress database error page
- Display Youtube Time Automate from Key
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- How to upload WP user avatar on woocommerce account page [closed]
- Where is the PHP code generating an element?
- Basic wpdb update question
- Ajax search shows all results when user empties input?
- Integrating Yii2 and WordPress
- List post by title length
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- Custom Registration username_exists / email_exists
- Need help with pagination
- After disabling WPML multi currency, the currency is still handled by the WPML
- How do i wrap woocomerce attribute in list?
- PHP Helper Class to create shortcodes
- Is it possible to add a custom page to a free WordPress site? [closed]
- save metabox with new values _wp_page_template
- pagination broken – clicking next displays “page not found”
- Editor capabilities – admin_init
- WP insert post Redirect after function has executed
- Create condition for Author bio Social Links
- How can I add diffrent editable text fields?
- Woocommerce template file outputting tags
- Featured image in menu wordpres
- Trying to update Woocommerce meta values
- retrieve “Link Color” value
- If Statement is Ignored?
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Create “blank” admin page without having admin-bar/admin-menu for faster load
- Need help transforming echo to return for use with shortcode
- Noob question: want to remove the “site identity” logo for specific part of website only
- Create Schema in WordPress with PHP
- Redirect after login depending on the URL
- Search only for posts with specific metadata?
- Real time notification on user profile after new comment
- How to add text before posts
- Add two or multiple functions in WordPress Post or Page
- How to associate dynamic PHP page for chosen WordPress tag?
- Only display notification on single post
- Where can I find the declaration of `$_wp_theme_features`?
- Static home page ignored
- How do I routinely extract the thumbnail of the most recent post?
- WordPress error on my website
- Display tab title as ‘blog tagline | blog title’
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Showing custom field contents without listing description
- Show custom default avatar instead of gravatar
- Best way to define a database with product codes and back-end support?
- wp_customize_image_control default value
- Check if values exists DB
- Widget header unique classes
- why is this content-template not showing any of my blog-entries?
- How to get the count for each taxonomy term
- How to add button to top of theme customizer?
- How can I add more code to this?
- Save Option on Database
- Edit the Publish Widget Options
- New to WordPress & Freelancing [closed]