Written by Sean Behan on Sun Jun 17th 2012

I didn't know this, but because of a linking problem using custom taxonomies in Wordpress, I was forced to find out. If you create a new taxonomy, it will not work immediately on the front facing end. Your users will be greeted by a 404, page not found instead. This isn't ideal for obvious reasons.

You create and/or register custom taxonomies like so. You may have multiple taxonomies.

add_action('init', 'create_my_taxonomy', 0);
function create_my_taxonomy(){
  register_taxonomy( 'musicians',
    'post',
    array(
      'hierarchical' => false,
      'label' => 'People who play lovely music that I like...',
      'query_var' => 'musicians',
      'rewrite' => array('slug'=>'musicians')
    )
  );
}
In your theme directory you need at "taxonomy.php" file. This will catch your custom taxonomy requests. You can get even more fancy and create a file like so "taxonomy-musicians.php" which you can use to differentiate your taxonomies look/feel. Nice and slick... however, you may be frustrated after following these two steps and be greeted with a friendly 404 page not found template instead.

Fear not, you need only visit the Admin >> Settings >> Permalinks page as a logged in admin to flush your rewrite rules and get linking and your correct custom taxonomy template file. Straight forward, unless if you didn't know that merely visiting the Permalinks Settings page would correct the problem. But Alas, you do!

Addendum

You must also have posts using the taxonomy! Otherwise, you will still get the page 404 not found! I'm not sure if there is a work around for this at the moment. Anyone know?

Tagged with..
#404 #admin #permalinks #taxonomies #taxonomy #Wordpress #Programming #Wordpress

Just finishing up brewing up some fresh ground comments...