WordPress Custom Tag Templates

Martin Brinkmann
Feb 3, 2010
Updated • Jul 24, 2016

Tags are an essential part of nearly every WordPress blog. Webmasters use tags to categorize posts similarly to how they are categorized with categories.

One side-effect of tagging posts in WordPress is that these tags are sometimes indexed by search engines. Visitors from those search engines will then see a page containing excerpts of the posts that have been tagged with a specific tag.

This can result in two problems for the webmaster: Problem one is indexation. It can happen that a tag page gets indexed instead of the actual post.

There are plugins that can deal with the issue, and most add canonical information to articles so that search engines know that they are the main source and not the tag page.

The second problem is that the tag page can irritate search engine users as they only see excerpts and not a single article. This can look like spam to some, and might have a negative impact on a visitor's perception of the page and the website in general.

We have posted an option to create custom tag pages in WordPress back in April of last year and that method is still valid and working.

WordPress Custom Tag Description

wordpress tag description

This method basically creates a new template file for each tag that the webmaster wants to customize. It can for instance be used to display an introduction to visitors so that they know what the page is about. This method allows the posting of media as well as text on the tag pages.

Posting those additional information can be beneficial to the search engine indexation of the tag page as well since it adds unique content to those pages.

The disadvantage of that method is that a new template file needs to be created for each tag that the webmaster wants to create a custom page for. This is impractical for websites with thousands of tags.

Another method was posted on the Likemind blog. This new method has been introduced in WordPress 2.8. It makes use of a new tag variable called description which can be added to the tag's template so that it will be displayed on the tag pages of the website.

Some WordPress themes come without a tag.php file. If that is the case it needs to be created and modified to include the description. The easiest way to do so is to copy the index.php file and rename the copy to tag.php. The following code needs to be added before the loop in tag.php

<!--Start Code-->
<?php $tag_desc = tag_description(); ?>
<?php if($tag_desc) : ?>
<div class="tag-description">
<?php print $tag_desc ;?>
<?php endif; ?>
<!--End Code-->

Each tag page will from then on display the tag's description if available. Tag descriptions can be edited in the Posts > Post Tags menu in the WordPress admin interface.

The benefit of this approach is that only one template needs to be created and that everything else can be handled from within the WordPress admin area. That tag description can also be used as the meta description. There are some disadvantages though as it is difficulty to add formatting and media to the description (if at all possible).

Wordpress Custom Tag Templates
Article Name
Wordpress Custom Tag Templates
Find out how to add code to WordPress tag pages to display a custom description on each tag's page on your WordPress website.
Ghacks Technology News

Previous Post: «
Next Post: «


  1. Ali Parsa said on December 23, 2010 at 7:54 pm

    Thanks , You Made My Day :)

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.