You can use pre_get_avatar
filter to manipulate comment avatar html and stop WP from getting a default avatar for the comment.
Passing a non-null value will effectively short-circuit get_avatar(),
passing the value through the ‘get_avatar’ filter and returning early.
E.g.
add_filter( 'pre_get_avatar', 'my_filter_pre_get_avatar', 10, 3 );
function my_filter_pre_get_avatar( $avatar_html, $id_or_email, $args ) {
if ( is_a( $id_or_email, 'WP_Comment' ) ) {
// Add more cases with elseif or use a switch statement here
if ( '1092' === $id_or_email->comment_ID ) {
// set avatar to whatever html you want
$avatar_html="<img class="avatar" src="" alt="Custom avatar">";
}
}
return $avatar_html;
}
Use this in your theme’s functions.php
file or in a custom plugin.
Related Posts:
- Wrong gravatar showing up?
- Cannot get local avatars to show [closed]
- WordPress shows admin’s avatar after editing a comment
- What should I do to make generated avatars different for anonymous comments?
- remove_filter( ‘comment_author’, ‘floated_admin_avatar’ ); doesn’t work
- Replace comment avatars and links at the same time
- woocommerce allow users to select or use avatar
- Best way to tell if a comment is from a user?
- Default Gravatar not showing for pings
- Upload avatar for post comment
- WordPress Custom Local Avatar not showing in comments
- How can I filter the user avatar displayed in comments? – get_avatar_url filter works everywhere but not in comments
- comments reply script not working
- Check If comment author is registered
- How do I set up real anonymous posting in bbpress forums? [closed]
- How do I turn off wordpress comments ability to capture a users ip address?
- Success message in comment form
- How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
- Is there a hook for comment author link?
- Exclude internal links from comment moderation?
- Change the HTML output of comments
- How to Block Access to Standard Login Flow and Comment Flow
- Upload images with comment
- Prevent Contributor to show comment list
- where to modify get_comment_author_link()?
- Change language of comments template
- How to get gravatar url alone
- Why Allow Script Commands in Comments?
- How to enable comments options?
- WordPress comment count to include attachment comments
- How to no follow the paginated comments
- Remove “Comments are closed” Notice from Custom Post Type template
- get the avatar url instead of an html img tag when using get_avatar?
- Comment count wrong with orphaned comments
- Comment form problem with comment_author_url and HTML5 input placeholders
- Pings and replies
- Comment_Reply_Link Not Showing?
- Display the number of unseen comments on a page since the user last visit
- Log in link not showing, Comment Issue
- WordPress comments on users profile
- wordpress threaded comments – customize nested ul / how child ul is displayd
- How to make a secure blog that is completely private?
- identify and delete spam comments from 3000 pending comments
- Hide comments column in WordPress backend
- WordPress Comments are automatically publishing
- Comment displaying full name even after setting another display name?
- How to move comments box above comments
- save_post action hook for comments
- Ability to leave comments broken
- How to disable comment flood temporarily in a single scope
- How to create a seperate commenting system?
- Change how many approved comments must user have
- Only admin can see comments on post or page
- Show comments of a user post only when they are login
- Display Custom comments field number
- How to get and use the the number of days since the last comment?
- Trying to post a wordpress comment on my site redirects to 127.0.0.1
- How do I add class to an admin comment?
- How can get comment link by comment id?
- How to amend time format of comments, using child-theme?
- Make user’s name display as the site name in comments if it matches certain roles
- Display avatar with comment form?
- Adding SQL source code to comments
- How to control size of comments popup window?
- How to make comments private for commentor and post author
- Name of comment field differs on different sites
- WordPress Spam Comment Filter
- Sent comments notifications to multiple users
- Adding avatars/gravatar to a WordPress blog
- Applying same style to all the comments on the page
- Customise Comment form
- assumed as comment line
- stumped on add_action hook to delete_comment – any ideas?
- Avoiding calls to theme-compat
- Allow tags between shortcode in comments
- Return count for characters in the comment and perform action based on the length
- How to load new posts from wordpress db into wordpress homepage without refreshing the site?
- Delete/Spam Comment Button
- Who approved a comment, to show up in dashboard
- comments.php remove date/time’s #hyperlink
- comment just attachment .. reply just text … can I do that?
- No comment Section but still got a Comment
- How to prevent users/authors from seing IP/email of new commentators?
- Why are my threaded comments not quite working? [closed]
- $post->comment_status always returns ‘closed’
- edit comments in front end
- How to replace anonymous comment form with a registration form on wordpress?
- I have tried using Plugins to remove 72K comments with no success
- How to get the 5 most recent comments and each comment 5 most recent replies (children)
- Redirect first time comments
- comment files and s
- Disqus moderation page not working in WordPress admin section
- How to hold all comments for moderation, including author’s comments on own post
- Comment forum to display under the comment you’re replying too
- Recent comments per tagged post?
- Subscribe to a post’s comments without posting a comment yourself
- How to hide the login / profile urls on top of comment box for a post
- wp_list_comments adds unnecessary elements
- Why default comment fields don’t show up?
- comment_approved custom value