Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Display Blog Post Meta Data in Your WordPress Themes

Do you want to learn how to display post meta data in your WordPress blog posts?

Meta data includes important information about your posts such as the publication date, the author’s name, and the tags. It may be useful to share some of this meta data with the people who visit your website.

In this article, we’ll show you how to display post meta data in WordPress posts easily.

How to display post meta data in WordPress themes

What is Post Meta Data in WordPress?

Blog post meta data is information about a post that’s not part of the actual content. This includes things like the publication date, the name of the author if you’re running a multi-author WordPress blog, categories and tags, custom taxonomies, and more.

Post meta data example

Depending on the WordPress theme you’re using, this information can appear in lots of different locations. For example, your theme might show the post meta data directly below the title, after your content, in your sidebar, or some other location.

Where ever it appears, this information can help visitors learn more about your content. It can also help them discover other interesting posts. For example, they may look for more blogs written by the same author.

In this way, your post meta data can improve the user experience, make your site look more professional, and even increase pageviews.

Just be cautious about displaying too much post meta data, as it can make your site look messy and unprofessional. It might even confuse the reader and damage the user experience.

Post meta data messy example

All WordPress themes handle post meta data differently. Some themes allow you to customize the post meta data without writing any code.

For example, some themes use the WordPress theme customizer to edit the meta data, while others will have their own theme options panel.

Theme customizer meta data example

Before you go any further, it’s smart to check the documentation for your WordPress theme, to see whether there’s an easy way to customize the post meta data without code.

If you’re unsure, then you can reach out to the theme’s developer for help. For lots of useful tips, please see our guide on how to properly ask for WordPress support and get it.

That being said, let’s show you how to display and customize the blog post meta data on your WordPress website.

How Do WordPress Themes Display Post Meta Data?

To display or change the post meta data you’ll need to add code to your WordPress files. If you haven’t done this before, then check out our step-by-step guide on how to copy and paste code in WordPress.

You can modify the individual theme files directly, but this makes it difficult to update your WordPress theme without losing customization.

For this reason, we recommend overriding the themes files by creating a child theme.

If you’re creating your own custom theme, then you can directly add or modify the code in your existing theme files.

There are lots of ways to display post meta data in a WordPress theme. Some themes will have simple code that’s located below the post title, as you can see in the following example:

By <?php the_author_posts_link(); ?> on <?php the_time('F jS, Y'); ?>  in <?php the_category(', '); ?> <?php edit_post_link(__('{Edit}'), ''); ?>

The code above simply displays the author’s name, post date, and categories.

Other themes may use their own template tags, functions, and classes to show meta data. Then, the themes files that are responsible for displaying posts can use these functions.

Usually, you will find post meta data code in your theme’s index.php, single.php, archive.php, and individual content templates.

Now we’ve covered that, let’s take a look at some examples of how to display different post meta data in your WordPress blog.

How to Display or Hide Post Date in WordPress

To display the post’s publication date, you need to add the following code to your theme:

<p>This article was published on: <?php the_time('m/j/y g:i A') ?></p>

This code simply shows the time and date when your post was published.

Pay special attention to the characters inside the_time function. These are called format characters, and they tell PHP how to format the date and time.

Here’s how the post meta data will appear to the people who visit your website:

Post meta date

If you want to hide the date meta data at any point, then simply find the code with the_time or the_date functions in your theme files and delete those lines.

How to Display Last Update Date for WordPress Posts

By regularly updating old articles, you can keep your website fresh and interesting and improve your WordPress SEO.

In this case, you may want to show the date when the post was last updated. This can help engage visitors who may not be interested in posts that were published years ago.

In your theme files, add the following code where you want to show the last updated date:

$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
echo "<p>Last modified on ";
the_modified_time('F jS, Y');
echo " at ";
echo "</p> ";

Here’s how the last updated date will look to your readers:

Post meta modified date

For more information, please see our complete guide on how to display the last update date of your posts in WordPress.

How to Show or Hide Author Name in WordPress

To display the author name, you need to add the following code to your theme files:

<p>This article was written by <?php the_author(); ?></p>

This code uses the_author tag, which shows the author name only:

Post meta author name

To help readers discover most posts by their favorite author, you may want to add a link to that author’s page.

To do this, simply replace the_author tag with the the_author_posts_link, as shown in the code below:

<p>View all articles by <?php the_author_posts_link(); ?></p>

If you want to hide the author’s name at any point, then just find the the_author or the_author_posts_link tags in your theme files and delete them.

How to Show or Hide Categories in WordPress Posts

Categories can help readers discover related content, which will improve the user experience and keep them on your website for longer.

That being said, you can show the categories on your blog posts using the following code:

<p>This post was filed under: <?php the_category(', ') ?></p>

In the following image, you can see how the categories will look to your readers:

Post meta categories

As you can see, the code shows all the post’s categories separated by a comma. You can replace the comma with any character you want to use by editing the code snippet above.

If you want to remove category meta data from your WordPress posts, then just find the line with the_category tag in your theme files and delete it.

How to Show or Hide Tags in WordPress Posts

Similar to categories, tags can help visitors find more content they’re interested in reading. To show the tags post meta data, simply add the following code to your theme files:

<p>Tags: <?php the_tags(); ?></p>

This code will show all of the post’s tags separated by a comma. You can replace the comma with any character you want to use instead.

For example, here we’re showing tags separated by a slash.

<?php the_tags( 'Tags: '/ ', ', '<br />' ); ?>

As you can see, the_tags function accepts three different values, known as parameters.

the_tags($before, $separator, $after)

You can use the before and after parameters to add any text or code that you want to show next to the tags. This allows you to add CSS classes, which you can then use to style how the tags appear on your website.

Let’s take a look at an example:

<?php the_tags('<div class="wpb-tags">Tags: ', '  ', '</div>');

Here’s how the post meta tags will appear on your website:

Post meta display tags

If you want to hide the tags from your readers at any point, then find the line with the_tags() code in your theme files, and delete it.

If you’re comfortable adding custom code to your WordPress website, then you can show a lot more meta data to your visitors.

For example, you can use custom fields to add your own meta data to WordPress posts. Another option is to create custom meta boxes to display the custom fields.

We hope this article helped you learn how to display blog post meta data in your WordPress themes. You may also want to see our guide on how to create a landing page with WordPress, or see our expert pick of the best landing page plugins.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

14 CommentsLeave a Reply

  1. I’m using code snippets and none of it work. I get the following error message “syntax error, unexpected ‘<', expecting end of file"

    • You may want to try adding above the code snippet you are trying to use the closing tag:


  2. Hey, great article. I want to display only one category on my blog. Let’s say if I have a post that comes under three categories, I want to display only one category out of three as metadata on a single post. How can I achieve it?

    • In those cases, it would normally be better to restructure your categories so the post would only be in one and use tags for organization


  3. Thanks a lot for this article! I have one question. Is it possible to hide Tags: and This post was filed under: in case no tags or categories are set?

    • It would depend on how your specific theme has added it and you would normally add a conditional statement. If you check with the support for your theme they may be able to assist.


  4. Hello,
    Wpbeginners helped me alot during my whole career. Thank You for all. I have a question that is there any role of published date and authors name in SEO? can it effect ranking ? I have a php website and I have published many posts but it doesn’t contain any author name or date. should I add these to my site ?

  5. Thanks for the info! So I’m trying to add a date to my posts. I saw your code but where is that added?

    Thank you!

    • It would depend on where you want to have the information displayed for where to add the code. If you reach out to the support for your current theme they should be able to point you to the right direction


  6. Hello, i have news aggregator site how to add on homepage after every post source name and time when is published post (example google | before 45 minutes

  7. Hello, I have added an author name using the code provided in the article, but the link goes to the home page and not to the all articles written by this author. Please advise, thank you in advance, Liudmyla

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.