How To Show Tags On A WordPress Theme

Since WordPress now has built-in tagging you might still need to add some code to older WordPress themes to get tags to show on your posts. Adding tags to your WordPress theme should be a pretty easy task.

There are numerous tagging plugins available that can do this for you. But if you want to control where the tags are shown on your WordPress blog then you might want to disable the plugins and edit the theme’s files to show the tags exactly where you want them to. The first and obvious file to add tags to is the single post template (single.php) file. The area to add the code to is typically at the end of the post (PHP the_content) and above and the comment section. In the example below I am showing the template tag in two different places. One is within the post meta data after the category and the other is on its own right before the comment section. The problem you might get into adding the tag code to the post meta-data is if you tend to use a lot of tags it could get to be a bit long and ugly. The code added below to show tags is:

https://gist.github.com/wpcount/41138628a85dd554c326f5604467bd1f#file-tags-php

and here is how it’s used in single.php

https://gist.github.com/wpcount/41138628a85dd554c326f5604467bd1f#file-single-php

To find the single.php file in the WordPress dashboard go to Appearance, Editor and click single.php on the right. If you don’t have a single.php file try index.php which is usually the main blogs page but may also be used on single posts for some themes. First, copy all the unedited theme code in the editor and paste it into a text file and save it for a quick backup in case you screw things up. Then find the correct location and paste in the tag code and save the file. Then check where the tags show. If you don’t like where they show, keep moving the code around and remember you might need to tag the post if the tags aren’t showing!

The above sample code is by no means the way it is going to be all themes and is only an example. Your theme might not look anything like the example above. And because of that, I couldn’t cover every theme variation. And please I can’t possible look at everyone’s theme code so please take some time to experiment with your theme.

Much more about WordPress template tags can be found on the Codex.

Disclosure: Some of the links in this article are affiliate links and we may earn a small commission if you make a purchase, which helps us to keep delivering quality content to you. Here is our disclosure policy.

Editorial Staff
Editorial Staff
Editorial Staff at WPArena is a team of WordPress experts led by Jazib Zaman. Page maintained by Jazib Zaman.

LEAVE A REPLY

Please enter your comment!
Please enter your name here
Captcha verification failed!
CAPTCHA user score failed. Please contact us!

spot_img

Related Articles

Why WordPress Is The Best CMS? (And, Possible Alternatives)

Why WordPress is the best CMS? Having a website has become a necessity for both individuals and businesses. Content Management...
Read More
When optimizing the speed of your WordPress site, you might come across a performance metric known as Time to First...
Are you dealing with a broken WordPress site and don't know what to do? If your website is showing a...