Original title: How to modify the user's default avatar in WordPress
How to modify the default Gravatar avatar of WordPress, that is, if visitors have their own Gravatar avatar, they will display it, if not, they will display it specified by the website.
Those who are familiar with WordPress should know that the default Gravatar avatar can be set under the background – setting – discussion, but the built-in icons are really not flattering. Fortunately, WordPress provides the avatar_defaults hook, allowing us to add custom avatars. Next, Chenyang SEO will share two ways to modify them.
How does WordPress modify a user's default avatar
Method 1: Use code to customize the default Gravatar avatar of WordPress
At the end of your topic's functions. php& gt; Add the following code before:
//Modify default avatar
add_filter(avatar_defaults, default_avatar);
function default_avatar($avatar_defaults) {
$myavatar = ;// Image URL path
$avatar_defaults[$myavatar] = "111";// Description name of the picture
return $avatar_defaults;
}
Modification prompt:
1. The fourth line of code is the URL address of the avatar. The above is wpdaxue-gravatar.jpg under the images folder of the active theme. Please modify it according to the actual situation;
2. The fifth line is the name of the user-defined avatar. The above is the default avatar of WordPress University. Please modify it yourself.
After saving, you can see the new avatar in the background - Settings - Discussion, and set it as the default:
Method 2: Use the Add New Default Avatar plug-in
If you don't want to waste code, you can also directly install the Add New Default Avatar plug-in in the background. After it is enabled, you can add a custom avatar in the background - Settings - Discussion, which is very simple. Go back to Sohu to see more
Editor in charge: