admin管理员组

文章数量:1277887

I noticed that if someone clicks on my Pinterest share button on a blog post, several unrelated images show up. I was able to use nopin="nopin" per Pinterest's documentation on most of these images to clean most of it up.

However, I have a custom avatar set in my functions.php...

//* Add new default gravatar to Settings » Discussion page */
add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = '.jpg';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}

If someone gets that avatar in a comment, then the image shows up as a choice on a Pinterest share. How do I add the nopin="nopin" attribute to this avatar image?

I found a similar post discussing this issue, but it's way over my head and seems a little different because he's using an array (lol, also over my head).

Any help is greatly appreciated!

I noticed that if someone clicks on my Pinterest share button on a blog post, several unrelated images show up. I was able to use nopin="nopin" per Pinterest's documentation on most of these images to clean most of it up.

However, I have a custom avatar set in my functions.php...

//* Add new default gravatar to Settings » Discussion page */
add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'https://www.fakedomain/wp-content/uploads/2017/03/PiggyBank.jpg';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}

If someone gets that avatar in a comment, then the image shows up as a choice on a Pinterest share. How do I add the nopin="nopin" attribute to this avatar image?

I found a similar post discussing this issue, but it's way over my head and seems a little different because he's using an array (lol, also over my head).

Any help is greatly appreciated!

Share Improve this question asked Oct 24, 2021 at 19:45 JimJim 71 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

You can try this one:

function wp_ste_add_nopin_args( $args ) {
    $extra_attr = 'nopin="nopin"';
    $args['extra_attr'] = $extra_attr;
    return $args;
}
add_filter( 'get_avatar_data', 'wp_ste_add_nopin_args', 999, 1 );

For further reading, please visit: https://developer.wordpress/reference/functions/get_avatar_data/

本文标签: customizationHow do I add nopinquotnopinquot to the default avatar