How To Add Author Details With Gravatar In WordPress Posts

How To Add Author Details With Gravatar In WordPress Posts

Many of you are having multi author blogs and may feel the need to show the author details on every posts published, some of you may have simple author but then also you’d like to add author details coz it looks kinda cool. Most of the premium professional themes comes with the added bonus but [...]

Many of you are having multi author blogs and may feel the need to show the author details on every posts published, some of you may have simple author but then also you’d like to add author details coz it looks kinda cool. Most of the premium professional themes comes with the added bonus but as i’m a free theme lover and hope you’re too, we can easily add it to our blog. I’ll show you how i added it in this blog and show you the different ways you can add it in your blog.

The Code

<div id=”post_author” class=”clearfix”>
<?php echo get_avatar( get_the_author_email(), ’80′ ); ?>
<div class=”author_desc”><h4>Author : <?php the_author_posts_link(); ?></h4>
<p><?php the_author_description(); ?></p></div>
</div>

This will create a author info like i have in my every post. Lets analyse the code,

get_avatar(get_the_author_email(),’80′) , imports the avatar from gravatar, 80 is the size you can change it if you want to.

the_author_posts_link(), imports the link to which all the posts of author are shown, you can also change it to some other options like author sitename, IM etc, checkout the functions listed below.

the_author_description(), its self explanatory it imports the description added by the author in users option in admin panel.

Some other functions you can try can be found here : Template Tags ( Check Author Tags)

The CSS

Ofcourse everyone knows the output have to be styled, heres the default CSS i use for my site, you can change it to what ever suits your need.

#post_author {
border: 1px solid #E8E8E8;
background: #EBF6FB;
padding: 10px;
margin: 20px auto 20px auto;
}
#post_author img {
float: left;
border: 1px solid #E8E8E8;
}
#post_author h4 {
font-size: 1.4em;
margin-bottom: 5px;
font-family: Arial, Helvetica, sans-serif;
}
#post_author p {
margin: 0;
padding: 0;
}
.author_desc {
padding-left: 95px;
}

If you don’t understand the CSS and need any type of help with modification of style ask in comment, me or some other users will surely answer or you can also try some basic tutorials on internet on CSS.

How To Add

The biggest question aint it, if your a geek you already figured out if not heres the process,

  1. Open style.css in your template and at the end of all CSS codes just paste the CSS lines in red above.
  2. Open single.php and find <?php the_content( ” ); ?> now if you want the author description to appear at the start of every post just paste the PHP Code high above in red, just before the line <?php the_content( ” ); ?>, if you want it to appear at end of every post paste it below the line <?php the_content( ” ); ?>

Please Check The Following Images For Example :

CSS Example

CSS Example

php

PHP Example

And your professonal author description is ready, add more details in the php using the other functions and change it to suit your needs its all upto you.

        


Related posts:

  1. How To Create A Page Peel Advertisement In WordPress !!
  2. How To Create A Simple Greenary Layout For WordPress In Photoshop
  3. How To Create A Cool Glossy Shiny Web 2.0 Heart in Photoshop
  4. How To Create Cool Shattered Rainbow Text Effect In Photoshop
  5. How To Design A Grey-Blue Blog Design In Photoshop – GreyFuture


User Comments


  1. lawrence77
    May 5th

    wow!
    Cool tips for beginners! :)

    lawrence77’s last blog post..Daily Inspiration #3

    Reply


  2. sbq
    Aug 31st

    thanks, just what I was looking for (i dropped a word for you on the wp forum)

    Reply


  3. BrandonSch
    Dec 16th

    Great post , You hit the
    mark with this, I just don’t understand why people quite get what you’re saying.
    I don’t know how many individuals I’ve talked to about this very
    thing in the past month, and they just can’t get it.

    , Excellent post!

    Reply


  4. ~ew
    Dec 26th

    Hello,

    Do note that, as of WordPress 2.9, the recommended way to query the author’s mail is by calling
    the_author_meta('user_email');

    Reply


  5. LarryLove
    Feb 25th

    Hey very nice blog!!….I’m an instant fan, I have bookmarked you and I’ll be checking back on a regular….See ya :)

    Reply


  6. DailyTechPost
    Sep 12th

    Great info…i was wondering how to add author info….it has surely helped me a lot….thanks for sharing :)

    Reply


  7. pankil
    May 9th

    i m just looking for this

    Reply


  8. Vinay Jhedu
    Jul 15th

    Hey thanx for this post i was looking for this post

    Reply


  9. Vinay Jhedu
    Jul 15th

    where to find these files styles.css and single.php

    Reply


    • Subhadeep
      Jul 15th

      you can find them in your theme files, which is located in wp-content/themes/

      Reply


  10. Brandon
    Jul 16th

    My question is how do you make the author description an excerpt. There does not appear to be any way to control the length of the author desc. In my case I am working on a site with 40+ contributors and cant afford to police peoples description length. Do you have any ideas how to do this, ala post excerpts?

    Reply


  11. Heather Wood
    Jul 17th

    I used the code you provided. I have applied the php code to the bottom of each of my posts using a hook. The gravatar and descriptions show up just fine.

    For some odd reason, my css doesn’t show up? Although, all my other hooks with css in the same area are working just fine. I haven’t a clue. its been driving me crazy for the past few hours now.

    I’ve tried using firebug to help me debug the issue with no luck. It just doesn’t show up. Please Help!

    http://www.ravenousravendesign.com/marketing/how-to-sell-yourself-as-a-designer/

    Reply


    • Subhadeep
      Jul 23rd

      Hi, this is not shortcode, so you don’t have to put it below every post, just add it in single.php theme file, if you are unable to do it contact techsip.com, they can do it for you for minimal charges.

      Reply


  12. Heather Wood
    Jul 22nd

    Please, I still need help. My CSS is not connecting with my author information. I have it set in each post, but css doesnt work. Copy and pasted exactly what you have. All my other css is working. :(

    Reply


    • Subhadeep
      Jul 23rd

      add the css in style.css and php code in single.php in your wordpress theme files and it wiill work.

      Reply


      • Heather Wood
        Aug 8th

        Thanks for replying. I figured it out. Something odd was happening because I copy and pasted the code from your site.

        For some odd reason, it was adding double quotes to my id’s and classes. even though there weren’t double quotes within what I pasted.

        All I did was retype the exact code I had pasted and VIOLA! it finally worked! Strange.

        Reply

Rss Feeds   Twitter Followers Email Updates