How to Use get_the_author_meta in WordPress to Show Author Info
Your author’s are the heart of most WordPress sites. They write your content, engage with your audience, and generally make the site work as it should. As such, you’ll often want to get WP author meta from the site so that you can show it off in your template. The way to get meta author tag information from WordPress is a handy function called
get_the_author_meta (or, if you don’t need to do any processing,
the_author_meta). Using this function is a great way to get the author meta fields from your WordPress users, and show those author fields in your WordPress theme templates.
Scroll down to learn more about how to use the function
get_the_author_meta and gain new insight on its nuances.
3 Common Issues to Know about
get_the_author_meta and WP Author Meta
get_author_namewas previously a way that WordPress offered to get a chosen author’s display name. Now, the best way to do that is
- To show (or display, echo, or print—you pick your word) your author information without otherwise processing it in PHP, you’ll want to use
the_author_meta(), the WordPress function that will default to showing the selected author fields. It is functionally equivalent to calling
get_the_authoris a useful WordPress function to find the author of the current post.
get_the_authorfunction collect the same data about the same user (when no WordPress user ID is specified). While it’s not deprecated, like
get_author_nameabove, it’s functionally the same as
Our Video About Using
get_the_author_meta for WordPress Author Bios:
In this video, David uses the
get_the_author_meta functions to fetch the
description or “Biographical Info” meta field from his WordPress user—essentially get the author bio. The video doesn’t use
get_author_name, but as we noted above, you could do those with
Step-by-Step Guide to Showing WordPress User Meta with
Here, we break down the three steps to make the meta author tag visible.
- First, you’ll want to do this inside of WordPress template files. Generally, this will mean that you’ll be editing a file in your WordPress child theme. Here’s our Quick Guide on making a child theme.
- Once in that file, you’ll probably want to be inside of “The Loop”, although the get_the_author_meta functions can work either inside or outside the loop. Inside, you’ll get to show the user email with
the_author_meta( 'user_email' ); outside, it would look like:
the_author_meta( 'user_email', 111 )(where 111 was this user’s
- That’s all! Because it’s what we showed off in the video, the user’s flexible “Biography” field is fetched with
get_the_user_meta( 'description' )and then made to have paragraph breaks with the
wpautopfunction. So, the final line of code was
echo wpautop( get_the_user_meta( 'description' ));. (
wpautopis a WordPress function which makes two line breaks into a paragraph-tag of HTML markup.)
With that, you should have a very solid understanding of how to show your WordPress author metadata and meta author bio using functions.
get_the_author_meta are powerful functions—it’s well worth your time to understand them in depth. Cheers!