I'd like to display the post author's name and avatar on posts sidebar but I can't find any info on it.

Is there a shortcode or piece of code to do this ?

Thanks for your help

  • Write your own widget :-) – Pieter Goosen Sep 10 '15 at 8:16
  • Well I'd love to, but I have no idea how to do this ;) Any function I should use ? – Graham Slick Sep 10 '15 at 8:20
  • Use get_queried_object()->post_author in single page view in the widget to get the post author ID and then take it from there – Pieter Goosen Sep 10 '15 at 8:22

if you are using it in Loop then :

You can display author name by using

<?php $author = get_the_author();
   echo $author; ?>

and you can display post author avatar using

<?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?>

you can change 32 size to whatever your need.

Hope this will work for you.


  • Thanks for your answer. Can I add this to the sidebar from the loop ? – Graham Slick Sep 10 '15 at 8:22
  • yes you can add this for single post also. but for single post, you have to put the post id to get author id and name or avatar. – Tech9logy Creators Sep 10 '15 at 8:25

Display author's name and avatar in Post page and single post page sidebar. Put this code in sidebar.php

        if(is_home() || is_single()){
           echo get_avatar( $post->post_author,'100');
           echo get_the_author($post->post_author);

I hope useful.


Display author's avatar and name in single page sidebar. Add this code in sidebar.php or single.php

if ( is_singular( 'post' ) ) {
    echo get_avatar( get_the_author_meta( 'user_email' ), 75 );
    echo get_the_author_meta( 'display_name' );

Here 75 number is the avatar size.

I hope it will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.