Displaying Author Meta Information in WordPress 2.8

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:

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:

And this code will give us a formatted output from the results:

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.

Fresh new author box

Originally, the code to render our author box with a gravatar, linked author name, and description looked something like this:

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.

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!

Posted Thursday, June 11th, 2009 · Back to Top


Add Comment

30 Comments 53 Mentions

  1. Montana Flynn Author Editor

    Real nice, I have mine hardcoded into my theme but this would be useful for guest posts and blogs with more than one author!
    [rq=4694,0,blog][/rq]Save some tree with virtual business cards!


  2. Callum Chapman Author Editor

    I’m hoping to get some guest bloggers on my blog soon, so this should turn out to be pretty useful! Thanks :)
    [rq=4807,0,blog][/rq]10 Beautiful Black & White Illustrations


  3. sonichtml Author Editor

    Nice~ thank you for shared..


  4. Sumesh Author Editor

    That’s a useful function – I’ve been looking at other slightly complicated workarounds to show author information, as it is on TUTS sites, Makeuseof.com etc.

    Saved on Delicious :)
    [rq=5323,0,blog][/rq]OldVersion.com: Get older versions of software


  5. Hezi Author Editor

    that simply ROCKS!


  6. lossendae Author Editor

    That’s cool and easy!


  7. henry Author Editor

    once again i have to thank you for making it easy to find helpful and useful wp tips!!!


  8. Tyler – Building Camelot Author Editor

    And what about the CSS? Can you use the same CSS code from the previous article and apply it here?
    .-= Tyler – Building Camelot´s last blog ..Weekly Round Table: Happy 4th of July! =-.


  9. Zach Dunn Author Editor


    The CSS should be able to translate over, since we’ve kept the same basic HTML structure.


  10. Tyler – Building Camelot Author Editor

    @Zach: Thanks for the response and for the code! It works perfectly and I’ll be sure to sent people this way if they ask how I got the code to work.

    One last thing if you don’t mind…what would I need to add to make sure this shows up on single pages only. I know it’s via “is_single()” but I don’t know how to modify the code to make the changes.

    Thank you!
    .-= Tyler – Building Camelot´s last blog ..Following Up With Vincent From The Dad Jam =-.


    • Zach Dunn Author Editor


      If you only need it to show up on blog posts/single pages, the answers actually pretty simple. You’ll want to put this code into the single.php template, right below the post loop.


  11. Andrew Author Editor

    Thank you for the easy to follow tutorial!

    How would I go about setting it so a post by the “Admin” account doesn’t show the author box?

    Also, Primer has a lot of guest posts, how would you recommend achieving an author box without making new accounts for every person that does a one-off guest post?

    Thanks again!
    .-= Andrew´s last blog ..Are You That Guy? =-.


  12. Jason Saggers Author Editor

    This works perfectly. the previous version didn’t for some reason.
    Could i just put this on the pages just as easy?


  13. mazyoyo Author Editor

    great tips, thanks for share.


  14. hanniz Author Editor


    how do you code this, if you want to display the author information before the list of the author (= The Loop). Do you need two Loops?


  15. Michael Krapf Author Editor

    This is very helpful. I’m stumped on how to get this to work for a “user” instead of “author”.

    has been with us since

    I’ve tried everything. Any ideas?

    Thank you


  16. Web Design Author Editor

    this was very helpful thanks for the info


  17. Billy McGovern Author Editor

    I have added the php to my single.php file and I reference the “authorbox” in my css file but, I still cant get it to format. It shows up but just as text and an image, no organization. Help?


  18. Dwaynne Author Editor

    Hi, Zach. I need some guidance here. I defined some custom fields in functions.php for my user profile screen and now I want to use a value entered in one of those fields to filter a list.

    Specifically I have a custom field named ‘Branch’ and I want to say if the value of Branch is St. Augustine then show me all the staff members in St. Augustine branch. I know the key to it is the get_the_author_meta/the_author_meta but I am not sure how to structure the query.

    Thanks in advance.


  19. best roulette system Author Editor

    Good entry thanks, needed some more pictures though.


  20. Free stickers Author Editor

    Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you can do with some pics to drive the message home a bit, but other than that, this is fantastic blog site. A fantastic read. I will definitely be back…


  21. mmoVZ Author Editor

    Thanks for this tutorial. I extended it a bit by adding the total number of posts and comments made by that author.


  22. Jacquelyn Degrate Author Editor

    continue with the the nice work on the site. Do like it! :p Could use some more frequent updates, but i am sure you got some better things to do like we all do.


  23. Virgil Author Editor

    Learn a lot, really useful information.


  24. Paddy Author Editor

    Your post information is very detailed.


  25. reverse phone lookup Author Editor

    I certainly did not realize that. Learnt something new right now! Thanks for that.


  26. LV hilton Author Editor

    connected with handbags utilised LV shoes It is right here that reproduction


  27. cloud based filtering Author Editor

    Thanks for sharing and posting meta.This helps us blogger using this meta.


  28. Ibrahim Author Editor

    It’s really great man :)


  29. Rick Author Editor

    thanks for the post. Prima Ideas. Very good.




Build Internet by One Mighty Roar. Since 2008.