Posting Author Info in WordPress

Posted January 25th, 2007 by Mike Cherim

On my main pages, any page with a sidebar, you’ll notice a little “Blog Author” box. Big deal, right? Well, what’s cool is how I got it there. It’s a feature I added to my latest WordPress theme. I think it’s neat. Since it can be implemented on any theme it is worth noting with an explanation of how other WordPress (WP) users can use the feature. I’ve logged into quite a few blog admin areas to know it’s under-utilized but this short tutorial may change that.

Tell ‘em “About Yourself”

The first thing you’ll want to do is log into your WP Admin, as the administrator, and head on over to the “Users” page. You should see “Your Profile and Personal Options” on the page. Scroll down until you see the “About Yourself” textarea with a label that says: “Share a little biographical information to fill out your profile. This may be shown publicly.” Just enter some text in that little box. When done click “Update Profile.”

Adding the Function to Your Blog

Via the “Theme Editor” on the “Presentation” page you need to add a little PHP snippet, a function call, in one of your theme files to activate the feature and display the text you entered in the form. This would typically be done in the “Sidebar” (sidebar.php). Here’s what you need to add:

 <−−To display content in paragraph form−−>
 <p>
  <?php the_author_description(); ?>
 </p>

Above I show it parsed with p-tags — the paragraph element — but you can create whatever you want. You could list the info as part of a typical sidebar set-up like so:

 <ul>
 <−−This is the part added (begin)−−>
   <li><h2>Author Info </h2>
    <ul>
     <li><?php the_author_description(); ?></li>
    </ul>
   </li>
 <−−This is the part added (end)−−>
 </ul>

That’s it. The info will display (hopefully styled).

But What About Multiple Authors?

If you blog with others displaying the primary author’s info may not suffice. To the best of my knowledge you can only display the primary blog author’s text. Thus I suggest adding content which introduces the group or team as a collective. In the case of an added image, such as that shown in my next example, I’d suggest adding a group shot or another image that represents the collective. Or, perhaps, maybe just a decorative image.

Adding it as a Blog Theme Option

If you’re making a WordPress theme for a client — or for distribution — you’ll want to make this an option so users won’t have empty mark-up on their pages should they choose not to use the feature. This is what I did (I even added an image):

 <?php  // To display the text with floated image if textarea has content
   $author_info=get_the_author_description();
     if($author_info != "") { ?> 

     <div>
      <img src="<?php bloginfo('template_directory'); ?>/images/bb_author.jpg" width="60" height="70" alt="" />
      <h2>Blog Author</h2>
       <p><?php the_author_description(); ?></p>
     </div>

 <?php } ?>

That looks to see if the the_author_description() function is outputting content. If it is, then the mark-up within the condition is added. Quite simple and straight forward, yet it’s something which is rarely used.

Getting More Specific

If you want to get more creative you can add a little bit more scripting to ensure it only displays on the home page or another page of your choice. I think that would be done like this:

 <?php  // For home page display only
   $author_info=get_the_author_description();
     if(($author_info != "") && is_home() && !is_paged()) { ?> 

     <div>
      <img src="<?php bloginfo('template_directory'); ?>/images/bb_author.jpg" width="60" height="70" alt="" />
      <h2>Blog Author</h2>
       <p><?php the_author_description(); ?></p>
     </div>

 <?php } ?>

Or, to display it on a specific page…

 <?php  // To display it on a specific page
   $author_info=get_the_author_description();
     if(($author_info != "") && is_page('ID or Name')){ ?> 

     <div>
      <img src="<?php bloginfo('template_directory'); ?>/images/bb_author.jpg" width="60" height="70" alt="" />
      <h2>Blog Author</h2>
       <p><?php the_author_description(); ?></p>
     </div>

 <?php } ?>

I haven’t tested the two examples above but I think the scripting has been offered correctly. If not, just comment and describe my syntax error and I’ll fix it :)


3 Responses to: “Posting Author Info in WordPress”

  1. David Zemens responds:
    Posted: January 25th, 2007 at 6:04 pm

    Thanks for pointing out that neat feature, Mike. After taking a close look at it, I see that you used a similar technique in your Seabeast theme, but that you control the content with the users_confg.php file. I commented out that feature and implemented your suggestion from this post, no controlled by the WordPress dashboard. Works great! Thanks again.

  2. Brian Thibault responds:
    Posted: January 25th, 2007 at 6:36 pm

    You should make this a wordpress plugin :)

  3. Anthony responds:
    Posted: February 4th, 2007 at 2:34 pm

    I guess with all this detail of how to add an author description I guess I have no excuse than to add one soon, I do think on blogs to know exactly who is the author is very important and encourages the personal relationship that blogs are great for building.

Sorry. Comments are closed.




Note: This is the end of the usable page. The image(s) below are preloaded for performance only.