News

WordPress Custom Tag Templates

3 Feb/10

Tags are an essential part of nearly every WordPress blog. Webmasters use tags to categorize posts. 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 that 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 that problem by adding canonical tags to those links so that the search engines know that the post page should be indexed with priority for the keyword and not the tags 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 spammy 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.

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 customize. This is impractical for websites with thousands of tags.

Another method was posted at 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 ;?>
</div>
<?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).

Continua a leggere – Original Link: WordPress Custom Tag Templates

Technorati Tags: , , , , , , , , , , ,

Realizzazione Sito Gestionale Immobiliare

Leggi Anche

Condividi
Condividi in DeliciousCondividi in DiggCondividi in RedditCondividi in StumbleCondividi in MixxCondividi in TecnoratiCondividi in Ok Notizie

Commenti

I commenti sono disabilitati per questo articolo.

I commenti sono chiusi.

Autore

    Spina Rosario
    Inserito da

Archivio

Iscrizione Newsletter

    Tieniti informato con tutte le novità del mondo informatico con la nostra newsletter
    Email:

    Nome:

    Auto Shop Italia
    Web Burning Blog
    Info Privacy

Meta