Wordpress Tutorial: Displaying metadata in your theme !
Displaying metadata
Trying to figure out how to display key information about your posts on WordPress, so your visitors can easily find them? Or maybe to add that professional touch to all your site? Let this article be your guide. We will walk you through the entire process and you will be able to call yourself a “Metadata Champ” in no time. Do read on…
What is Post Meta data?
Metadata is basically the administrative information related to every post you publish on WordPress. This data is usually not part of the content itself but contains relevant information about the post like the date it was published, the author, categories, relevanttags, and other key information specific to the post. Most
of the time, this information is placed right next to the post, although it can be tweaked to display in any part of the page, all depending on your WordPress theme.
How do I make Post Meta data information display in WordPress?
Based on the theme you use for your WordPress there are several ways to do this. Basically, metadata information is displayed using a few lines of code in your site but no worries, you don’t need to be a web
developer to be able to do it as you can basically use templates. For example:
This code displays the author name, date, and category of the post.
The basic WordPress theme places post meta data basic information and tags below your post in a box, before the comments.
Depending on your theme you choose, this arrangement can differ, but you should be able to find all the templates for displaying post meta data under the theme’s index.php, single.php, archive.php. You may also create a custom theme to easily add or edit code in your theme files.
Let’s see some examples of how to display various post meta data in WordPress.
- Displaying your Date for WordPress posts: You can display the '’last updated’’ date by copying and pasting this code to your WordPress theme file:
- And it will give you this result:
Display or Hide Author name
To display the author’s name, copy and paste this code into your theme files:
To link the author’s name to all posts they wrote use:
- The result is:
How to Show or Hide Categories in WordPress Theme
To show a category, copy and paste the following code into your theme files:
This creates the categories and separates them with a comma. You can use any other character of your choice as a separator to improve the aesthetics of your site.
To hide a category, add this code to your theme files simply locate the line with a the_category tag in your theme files and delete.
Display Post Tags
To display post tags, simply add this code to your theme files:
And there you have it. The basic tweaks you can make to add metadata to your WordPress themes.
You may explore more by using '’custom themes’’ to add your own metadata to your theme files after you master the basic ones.
Happy learning!
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Hey @osblog I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x