Skip to content

This is a quick technical reference for web developers on how to display the author name in WordPress posts. Use the code below to show the author name anywhere on your WordPress website without the use of a plugin.

Best of all, you can do this without a plugin!

Often, website developers are asked to add certain metadata to WordPress blog posts. Most commonly, that means displaying the author’s name and the post’s publication date.

Most WordPress themes have some kind of templated approach for accomplishing this. Or, website owners choose to install plugins that make it easier to manage and add post metadata. This is why WordPress is such a great choice for business websites.

Surprisingly, sometimes these options aren’t suitable, or appealing. Therefore, I created a way to incorporate the Author and Last Modified Date using a single shortcode.

Importantly, you’ll need access to edit the website’s functions.php file.

How to display the Author name

Function: get_the_author()

The first step for displaying the author name in a WordPress post is to use this handy function.

This will return the author’s name for the current post (or a given post_id) that can be passed in as a function argument.

Now, it might also be nice to display the publish date for the post as well…

How to get the Last Updated Date

Function: get_the_modified_date()

This function is pretty self-explanatory – it’s the date when the post was last updated. For a given post_id, the most recent modified date is retrieved and returned in date format.

WordPress date formatting in PHP

Using PHP, it’s easy to display date formats in many ways. Here are some examples which can be used in conjunction with the aforementioned get_the_modified_date() function.

// To show: 12:49:00 PM
echo date('h:i:s P');
// To show: Monday, 11:04:09 AM
echo date('l, h:i:s A');
// To show: 10 January 2020, 08:45:00 PM
echo date('d F Y, h:i:s P');

Code to show author name in any WordPress post

Finally, ensure you have (one of) these functions in your theme’s functions.php file. This is the secret sauce for how to show the author name anywhere in WordPress content.

Then, add the corresponding shortcode into your WordPress blog post or page to display the author name.

Do you need help accomplishing this on your website? My WordPress development services are perfect for people who are short on time.

SPONSORED HOSTING OFFER

Get 3 months free hosting!

When you purchase an annual Startup, Growth, or Scale plan from WPEngine using a special offer coupon code.

WPEngine Agency Partner
nv-author-image

Jason Shaw

With an Engineering degree and over 15 years of experience in web development, I’ve helped many businesses solve complex website and SEO issues. As the founder of Decodist (and small business owner) I can help you become more successful online.