the_author_meta() vs get_the_author_meta()

If you look at the source code for the_author_meta(), it simply, in essence, just echo’s the result from get_the_author_meta().

WordPress has quite a lot of functions where functions with a the_* prefix simply echos the results from its get_* counter parts. The get_* prefix is almost always used for functions which return its results.

There is really no performance differences between the two functions here, and you can use anyone to your liking, although each actually has each own specific use. Use the_author_meta() if you need to display the data, it looks a bit nutty to use echo get_the_author_meta(). Use get_the_author_meta() if you need to store the data for later use, or in shortcodes which require returned content

EDIT

You can always look up the source code on https://developer.wordpress.org, something you should always do. Never ever take something for granted. Just an example of the above, get_the_content() return unfiltered, raw post content, the_content returns the filtered content from the get_the_content(), so they are vastly apart in what they do

EDIT 2

….is there a third better alternative

If you look at the source code from get_the_author_meta(), it uses get_userdata() which returns all the fields you might be interested in

Leave a Comment