StylizedWeb is a web design trends and tutorials blog, maintained by Ross Johnson who also runs a web design company and design blog.

Categories Archive

Popular Posts
Advertisement
Basecamp The Web Design Sketchbook
Najbolje ponuda IT poslova u Srbiji na itposlovi.info Advertise on Stylized Web

WordPress post author description

add to Save to Delicious Save to Stumble Save to Digg

Lots of words these days about WordPress, people are getting more and more interested in high quality themes with lots of features, so ussual thing to have became post author info very useful if you have more writers. There was a guest post a bit earlier how to make a post author info outside main loop.

Now here's a tutorial how to make a author description with link, image and everything in two ways. You can see similar thing for example on Gemini Theme

Vector people

Let's get started! You'll use this on single.php and the usual structure for it goes something like:

 
 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
...
<?php the_content('Read the rest'); ?>
...
          <?php comments_template(); ?>
          <!--
          <?php trackback_rdf(); ?>
          -->
 <?php endwhile;  endif; ?>
 

And now we'll add some template tags to show author description (small note, there are probably some plugins for all this, so fell free to look for them). Most common things you would like to show are author image, name, url and description. Here's new code

 
 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
...
<?php the_content('Read the rest'); ?>
...
<div class="author">
              <?php   echo get_avatar( get_the_author_id(), '65' );   ?> <strong><a href="<?php the_author_url(); ?> "><?php the_author(); ?></a></strong>
 
 <?php the_author_description(); ?> 
</div>
 
<!-- author -->   
 
          <?php comments_template(); ?>
          <!--
          <?php trackback_rdf(); ?>
          -->
 <?php endwhile;  endif; ?>
 

If you have used "get_avatar" you will notice that we are using a different parameter than in comments ("get_comment_author_email()"). 65 is an image size, and here's how get_avatar function works (you can read more about it on codex)

 
<?php
   echo get_avatar( $id_or_email, $size = '96', $default = '
<path_to_url>' );
?>
 

So, this will generate and image with author info, and of course you should give that image some styling, in this case you can't use class because of the functions so you'll have to define it in CSS, something like .author img { border, float.... }

Here's another way if you are not using gravatars and you want to use some custom images made by kailoon http://themetation.com/2008/07/08/how-to-display-author-photo-in-wordpres/
Of course there's a third way by using custom fields, but we'll do it some other time

Further reading WordPress codex, and further idea, you can put some if-else so if there is not description to show some text etc..

Leave a comment on Stylized Web Have some feedback? Leave a comment



Talk of the town
  • South West Balloon Flights: Thanks for the script. Looks nice.
  • Tony: How about WP Super Cache. Google now takes into account a site’s loading time and what better way to...
  • Emek Elektrik: Thanks Adminstrator For Dar Gelirli Users…
  • Nelly: That is a good article for css thank you admin
  • Nelly: I want to learn css Can anyone help me? Thanks a lot
Amigos

What do you think?





8 Responses so far

By Erotik Hikayelerim
on September 25, 2009

Thank yuo

By Cristescu Bogdan
on September 19, 2009

Can you tell me what plugin use for this nice display code?

By mary
on October 15, 2008

very nice article, thanks for sharing!

By Basilakis
on October 15, 2008

Yes, u can put the slag, and make the post that way so theadds code will be after it.

And yes, it was a beatifull article :_)

By Foomandoonian
on October 15, 2008

Is there any fancy code that can move the start of the article text ABOVE the huge ad block?

  1. Dec 29, 2008: Wordpress Updates » Blog Archive » Author Profiles for Posts
  2. Nov 2, 2008: Best Of Design - October :: Elite By Design
  3. Oct 15, 2008: WordPress post author description