[Resolved] Getting avatar to show next to author name on post pages

Home Forums Support [Resolved] Getting avatar to show next to author name on post pages

Home Forums Support Getting avatar to show next to author name on post pages

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #743263
    Kevin Wabiszewski

    Hello,

    I am trying to get my gravatar icon to show next to the author name on my website

    Tom sent me this link

    https://generatepress.com/forums/topic/add-author-photo-for-each-post-in-blog-home/#post-335202

    I posted it into the code snippets plugin but the gravitar still does not seem to be showing. Any advice?

    #743266
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can edit the original topic and use the private URL field.

    Let me know 🙂

    #743278
    Kevin Wabiszewski

    Yes this isn’t the same website I will be using the theme on but you can see the setup here.

    https://www.dronetobewild.com/best-drone-for-beginners-review/

    #743280
    Leo
    Staff
    Customer Support

    I just tried the exact snippet using Code Snippets plugin and it’s working for me:
    https://www.screencast.com/t/KQlvkXHpW

    So you’ve added the snippet to the site you linked above and the snippet itself is activated?

    #743282
    Kevin Wabiszewski

    Thanks for the quick response. Did you just paste it into the code snippets plugin? Anything else I need to do? Maybe it is because I made the date and author unclickable.

    #743285
    Leo
    Staff
    Customer Support

    Yup probably. Can you temporarily remove other code and just make sure this one is working?

    #743322
    Kevin Wabiszewski

    Yeah that was the problem. Now I need to figure out how to get them to work together haha.

    #743335
    Leo
    Staff
    Customer Support

    OK try removing everything you have before and just add this:

    add_filter( 'generate_post_author_output', 'tu_add_author_gravatar' );
    function tu_add_author_gravatar() {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s %5$s<span class="author-name" itemprop="name">%4$s</span></span>',
    			__( 'by','generatepress'),
    			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
    			esc_html( get_the_author() ),
    			get_avatar( get_the_author_meta( 'ID' ) )
    		)
    	);
    }
    add_filter( 'generate_post_date_output','tu_remove_date_link', 10, 2 );
    function tu_remove_date_link( $output, $time_string ) {
    	printf( '<span class="posted-on">%s</span>',
    		$time_string
    	);
    }
    #743346
    Kevin Wabiszewski

    Thanks a lot Leo! I will try that out and let you know if it works.

    #743347
    Kevin Wabiszewski

    It worked thanks man!

    #743355
    Leo
    Staff
    Customer Support

    Glad I could help 🙂

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.