show author avatar

The get_the_author_meta function gets the Post’s author ID, not the comment-author’s information. The get_avatar() function is perfectly capable of accepting the comment object whole and working it out from that all by itself. So just call it like so: echo get_avatar( $comment, 32 );

remove_filter( ‘comment_author’, ‘floated_admin_avatar’ ); doesn’t work

As usual with hooks this is issue of timing. your init function is hooked to admin load process, which works fine for most things; however in this specific case function is added to filter in constructor of WP_Comments_List_Table class, and object is created in edit-comments.php after admin loader had been processed. In my plugin for … Read more

get the avatar url instead of an html img tag when using get_avatar?

It’s fairly simple to construct the Gravatar URL yourself, it’s just an MD5 hash of the user’s email address. <?php $gravatar=”http://www.gravatar.com/avatar/” . md5(strtolower($email)) . ‘&s=32’; ?> <div class=”avatar” style=”background: url(<?php echo $gravatar ?>);” ></div> The s parameter at the end there defines the size of the image in pixels. Using Gravatars – WordPress Codex

How to output nothing instead of default avatar?

You can use the get_avatar filter to change the output or avatar_defaults to add new image that can be placed on your server. Here is an example code for adding new avatar that you can set as default from the Settings > Discussion page. add_filter( ‘avatar_defaults’, ‘add_new_gravatar_image’ ); function add_new_gravatar_image($avatar_defaults) { $myavatar=”http://yoursite.com/image.png”; $avatar_defaults[$myavatar] = “Default … Read more

Listing all users by their avatars in wordpress

You can jump start by using following example. Here I’ll be listing users and loop through them to display avatar and display name. <?php $blogusers = get_users(); // Array of WP_User objects. foreach ( $blogusers as $user ) { /* Here passing user email and avater size */ echo get_avatar( $user->user_email , 96 ); echo … Read more

Get only the author profile picture image url inside a loop

Putting the following inside loop should fulfill your needs: <?php $get_author_id = get_the_author_meta(‘ID’); $get_author_gravatar = get_avatar_url($get_author_id, array(‘size’ => 450)); if(has_post_thumbnail()){ the_post_thumbnail(); } else { echo ‘<img src=”‘.$get_author_gravatar.'” alt=”‘.get_the_title().'” />’; } ?>

Inserting PHP before a menu element, while using the inbuilt menu function wp_nav_menu()

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 … Read more