• Resolved matustheboss

    (@matustheboss)


    I’d like to display gravatar next to author’s name in entry meta above posts.
    I’m using your plugin for customization entry metas.
    But it seems there is no shortcode for displaying author’s gravatar.

    Here’s an article showing what I’d like to achieve.

    I followed this tutorial, but from some reason, I didn’t get to manage the gravatar to show.
    Maybe there’s a conflict when using Genesis Simple Edits plugin.

    I’ll appreciate any help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Please add this code to your child theme’s functions.php file. I modified the code which I got from here: https://www.wpbeginner.com/wp-tutorials/how-to-add-an-author-info-box-in-wordpress-posts/ By the way it’s a very trustworthy website.

    function wpb_author_info_box( $content ) {
    
    	global $post;
    
    	// Detect if it is a single post with a post author
    
    	if ( is_single() && isset( $post->post_author ) ) {
    	
    		$author_details = '<p class="my-author-gravatar">' . get_avatar( get_the_author_meta('user_email') , 90 ) . '</p>';
    		
    		// Pass all this info to post content  
    		$content =  $author_details . $content;
    		
    		return $content;
        }
    
    }
    	
    	
    // Add our function to the post content filter 
    add_action( 'the_content', 'wpb_author_info_box' );	
    	
    

    Please share your website url.

    CSS:

    .my-author-gravatar img {
    border: 1px solid #D8D8D8;
    border-radius: 50%;
    float: left;
    margin: 0 10px 10px 0;
    }
    Thread Starter matustheboss

    (@matustheboss)

    Thanks! I solved my question meanwhile you wrote me.
    And yes, I agree WPBeginner is amazing website.

    Btw, it is also possible with adding this php echo code
    whenever I want to display the avatar:
    <?php echo get_avatar(get_the_author_meta('email'), 30); ?>

    30 means 30px.

    Thanks again ??

    You’re welcome. I didn’t know 30 meant 30px

    ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display ?? gravatar in entry meta post info?’ is closed to new replies.