Displaying Author Meta Information in WordPress 2.8
One of the (many) nice updates the comes bundled in WordPress 2.8 is with the_author_meta() template tag. This tag allows a developer to pull and display specific parts of any user’s information within a theme. Even though variations of this have been included in previous releases, this version has simplified it to a much easier syntax.
In this quick overview, we’ll look at some potential uses for the recently overhauled Author Meta template tag. Keep in mind that all of these demonstrations are done within a WordPress 2.8 installation. If you do not have this version running, these tags will not work as intended.
Displaying the Data
Especially if your site has registered users, this is an easy way to personalize your blog’s theme for each one. Let’s say you wanted to provide users a way to contact you by email:
<p>Get in touch with <a href="mailto:<?php the_author_meta('user_email'); ?>"><?php the_author_meta('user_firstname'); ?> via Email</a></p>
The above code will link to the email address of the author using their first name as anchor text.
Sample Output: Get in touch with Zach via Email
With the new author_meta options, information is displayed when the tag is called. If you’re looking to format the data first, you’ll need a different tag. Lucky for you, that’s exactly what the next section covers.
Manipulating the Data
Keep in mind that the_author_meta() tag is only meant to be used to display the contents. If you’re looking to manipulate or format the contents of a field, you’ll have to use a slightly different variation of the tag. This is where get_the_author_meta() comes in.
This template tag follows the same idea of retrieving author meta information, but it does not automatically display the contents. Here’s an example using date formatting:
<?php
//Format the author's registration date
$register_date = date("m/d/Y", strtotime(get_the_author_meta('user_registered')));
?>
And this code will give us a formatted output from the results:
<p><?php the_author_meta('user_firstname'); ?> has been with us since <?php echo $register_date; ?></p>
Sample Output: Zach has been with us since 06/01/09
As you can see, the result finds the registration date of the user, and then formats it from the original timestamp into something much more pleasant to read. Not bad for a couple lines of code!
Build an Updated Author Box
One of our earliest tutorials was on how to create an “About the Author” box within WordPress 2.7. The tags used there are now deprecated with this update, so let’s take a moment to refresh our code and stay fresh.

Originally, the code to render our author box with a gravatar, linked author name, and description looked something like this:
<div id="authorbox">
<?php if (function_exists('get_avatar')) { echo get_avatar(get_the_author_email(), '80' ); }?>
<div>
<h4>About <?php the_author_posts_link(); ?></h4>
<p><?php the_author_description(); ?></p>
</div>
</div>
As you can see, the previously used tags don’t really follow a single format. Now let’s take a look at the same result using the updated WordPress 2.8 tags. For the sake of education, we’ll be replacing the author post link with an anchor to their website’s URL instead.
<div id="authorbox">
<?php if (function_exists('get_avatar')) { echo get_avatar(get_the_author_meta('user_email'), '80'); }?>
<div>
<h4>About <a href="<?php the_author_meta('user_url'); ?>"><?php the_author_meta('display_name'); ?></a></h4>
<p><?php the_author_meta('description'); ?></p>
</div>
</div>
Even though this didn’t condense the code, it does become easier to skim through on the code end. For the most part, it’s very easy to read the tags involved.
Notice that in the case of our gravatar email, we’re only interested in getting the value as a string and not in displaying it. This is the something that is easy to get caught up with, and should be one of the first checks whenever you’re experiencing errors.
Break It Down!
As demonstrated above, this seemingly tiny update makes it monumentally easier to pull specific information about the author and display it as you please. From here, it’s just a matter of finding new ways to break down specific components in new and creative ways.
Have any ideas for clever applications? Let the rest of us recently upgraded WordPress fiends in on it too!



