Thesis Custom Taxonomy Pages that Visitors and Search Engines Will Love

Taxonomies in WordPress Edit-Post Sidebar Taxonomies in WordPress are categorized tags. They are useful if you find yourself adding a

Tweet This

Written by Damon on June 12, 2009
Taxonomies in WordPress Edit-Post Sidebar

Taxonomies in WordPress Edit-Post Sidebar

Taxonomies in WordPress are categorized tags. They are useful if you find yourself adding a class of tags over and over, like ingredients on a recipe blog. WordPress 2.8 includes updates that make the hidden taxonomy features easier to use.

I’ve set taxonomies up on my home-brewing blog, Life With Beer, where I have taxonomies for malts, hops, yeast strains, and adjuncts (weird stuff in beer like fruit, spices, and mushrooms). I also sometimes write about local craft-brewed beer, so I also have a craft-brew taxonomy that I use for micro-breweries and brew-pubs.

As an example of how you can use taxonomies to expand your blog to include information that visitors and search engines will love, I’ll be using a post from Life With Beer about kelp beer. (The link takes you to the end of the post where the taxonomies are listed. At the time of writing, it’s the only post where I’m using taxonomies, but it’s enough to illustrate the idea.)

To start using taxonomies, you need to dig through the WordPress Codex to find the relevant functions and add them to your theme. Or you can use Joost de Valk’s taxonomy plugin.

By default, the taxonomy pages look just like your regular tag pages, which is kind of boring, and at best will help a small percentage of visitors navigate your site. But, with just a little extra information on the taxonomy page you can create pages of keyword-rich useful information that visitors and search engines will love.

Taxonomies Linking Brewing Recipes with Ingredients

Taxonomies Linking Brewing Recipes with Ingredients

Coding Your Thesis Taxonomy Pages

Thesis doesn’t do well creating a page title for taxonomy pages, so the first thing we need to do is fix that.

Right under the title, we want to add some extra introductory content. To do that we’re going to roll our own WordPress query that only gets a post with the same page name as the taxonomy slug and print it out.

Since I want all of this to be grouped together, I’m putting it in the same function and using the bottom-border of #archive_info to separate it from the list of posts that are associated with the tag.

The second function creates text that introduces the list of posts that are associated with the taxonomy.

Read through the code comments, because there’s are a couple of areas that need special attention.


function custom_taxonomy_intro(){
	global $wp_query, $thesis;
	if ( is_tax() ) {	
	
/*
 * get taxonomy variables that we'll	use
 * to create a page title
 * and query the database
 * for information stored in a private post
*/	
		$taxonomy 	= get_taxonomy ( get_query_var('taxonomy') );
		$term = $wp_query->get_queried_object();
		$title = $term->name;
		$query_term = get_query_var('term');
/*
 * create headline
 * 
*/
		
		?>
		

label ;?> Archive

<?php thesis_hook_after_headline($post_count); echo "
"; //end headline_area /* * custom WP_Query that only * gets pages with the same name * as the taxonomy term */ $query='pagename='.$query_term; $tax_post = new WP_Query(); $tax_post->query($query); //Wordpress loop while ($tax_post->have_posts()) : $tax_post->the_post(); $post_image = thesis_post_image_info('image'); if ($post_image['show'] && $post_image['y'] == 'before-post'){ echo $post_image['output']; } echo "
"; the_content(); echo "
"; endwhile; echo "
"; //end post_box top } } add_action('thesis_hook_before_content','custom_taxonomy_intro'); function custom_taxonomy_post_list(){ global $wp_query; if (is_tax()){ $term = $wp_query->get_queried_object(); $title = $term->name; /* * create intro text * by concatenating text with term * adjust to your needs */ if ( is_tax('craft-brew')){ $pre="Posts about "; } else { $pre="Recipes that use "; } echo "

".$pre." ".$title.":

"; //add #taxonomy-intro to custom-css file } } add_action('thesis_hook_archive_info','custom_taxonomy_post_list');

Notes on Taxonomy Pages

You need to create a page to hold the introductory content with the same title as the taxonomy term. This page isn’t intended to be accessed by visitors or search engines, it’s just there to hold the unique content that you’re going to use at the start of your taxonomy page.

If you’re having problems and are using post titles in your URLs, check that the last segment of the permalink for the holder page, matches the last segment of the taxonomy page URL. On Life With Beer, my matching URLs for roast barley in my malts taxonomy look like this:

Holder Page: http://www.yoursite.com/roast-barley
Taxonomy Page: http://www.yoursite.com/malts/roast-barley

SEO Issues for Taxonomy Pages

You want search engines to crawl these taxonomy pages.

To avoid duplicate content penalties, you don’t want to allow search engines to access the holder pages. The easiest way to do this is to keep these pages private. This keeps the holder pages out of search engines, stops it from popping up in standard WordPress functions, and gives a 404 error to anyone who guesses the URL (after reading this article?).

Wordpress Page Privacy Settings

Wordpress Page Privacy Settings

The All-In-One SEO plugin treats these pages like tag pages and prevents search engines from crawling the taxonomy pages.

Thesis doesn’t recognize taxonomy pages (actually, both Thesis and All-In-One SEO both don’t recognize taxonomies, but Thesis uses a more strict function when excluding tag pages). So, even if you’re excluding search engines from your tag pages, search engines are still able to crawl your taxonomy pages which is exactly what we want.

All other things being equal, it’s better to dump the All-In-One SEO plugin and just use Thesis’s SEO functions. Alternately, bug the All-In-One SEO plugin people to add the option to decide whether to block search engines from taxonomy pages.


1 reply to “Thesis Custom Taxonomy Pages that Visitors and Search Engines Will Love

  1. vvvvv

    hey damon, thanks for this post.
    i’d like to know, for themes outside of thesis, and for someone using the simple taxonomies plugin, could you direct me to the part of your code block that tells WP to run a query to show all posts under a certain taxonomy? i understand taxonomy is on the same floor as a post-tag or a category, so it’s technically the same as asking for, “show me anything that has a tag” but actually, for example, if i gave something a taxonomy of WORK and variations with the term of ILLUSTRATION, LAYOUT, LOGOTYPE, etc, it would be reasonable to try to query for all posts that fall under the taxonomy of WORK. sorry for being long winded, i hope you can help to point towards a solution. best and thanks

    Reply

Leave a Reply

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