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:

and here is how it’s used in 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.

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 comment

Your email address will not be published. Required fields are marked *