Support » Fixing WordPress » Taxonomy template file in custom theme

  • Hi,

    I am trying to build a WP website with a custom theme which I am trying to code from scratch.

    Most of it is coming together fine but I am really stumped on taxonomy templates.

    I have create a custom post type of products and a custom taxonomy related to products called product-type. Now I am trying to get a list of all the products in a particular product-type which I believe should mean creating a taxonomy.php file in the theme and doing all the code in there, however whenever I visit the taxonomy page I just get the default index.php page.

    I have used the following code to pull out the URL’s for the taxonomy terms so the URL’s should be correct.

    $product_types = get_terms('product_type', 'orderby=count&hide_empty=0');
    	foreach($product_types as $product_type) {
    		echo '<p>' .$product_type->name. ' - ' .$product_type->slug. '</p>';

    In my functions file I have create the products custom post type and the product_type custom taxonomy using the following code:

    			'label' => __('Product Type'),
    			'sort' => true,
    			'rewrite' => array( 'slug' => 'product-type', 'with_front' => false )
    		'labels' => array (
    			'name' => __('Products'),
    			'singular_name' => __('Product')
    		'public' => true,
    		'supports' => array(
    		'taxonomies' => array(
Viewing 12 replies - 1 through 12 (of 12 total)
  • I was wondering if it was something to do with the ‘with_front’ setting but I’ve not been able to find anything to do with that which has made anything work.

    No one got an idea on this one?

    We’re having the exact same error and I cannot find any info out there for this. Does anyone have any ideas?

    dunno if this helps or not, but it’s not just a taxonomy.php you make.

    I have a custom tax called product_category associated with a CPT

    so I made a file called taxonomy-product_category.php which works perfectly

    didn’t need to do any custom query or anything…..

    I’ve tried this but it didn’t work either. What is a CPT? Sorry, I’m kinda new to WordPress.

    We have a custom tax called “tax_course” so I created a “taxonomy-tax_course.php” template and it doesn’t work, goes straight to index.php page.

    According to the WordPress documentation, if it doesn’t find that taxonomy-[custom_tax_name].php page it goes on to the taxonomy.php page.

    None of this is working for us and we can’t figure out why.

    Yeah, I can confirm that I couldn’t get this to work either. taxonomy-(insert your post_type here).php doesn’t work. One thing I could do is force a query in a page template or before any instance of the loop. Just before the posts loop do

    <?php query_posts("post_type=somenewtype"); ?>

    Where somenewtype is the new kind of post_type taxonomy you wish to display. If you want to do a taxonomy tag-like query, can do

    <?php query_posts("post_type=somenewtype&my_registered_tax=somevalue"); ?>



    Yeah, I can confirm that I couldn’t get this to work either. taxonomy-(insert your post_type here).php doesn’t work.

    It actually works. It’s taxonomy-(insert your taxonomy here).php that works.



    Thanks for the reply Abingabanger. Has anyone come across an example post of this working with a custom taxonomy page? I ended up having to use a page template and reworking the query before the loop. Using a taxonomy-xxx.php would have been much cleaner. I’ve found many sites on implementing the taxonomy but actually displaying the contents via the theme hierarchy has left me at a loss 🙁



    Well I have lots of trial and I couldnt get it to work with the taxonomy-taxonomy-(insert your taxonomy here).php
    then I tried to use

    single-(insert your taxonomy here).php

    ans surprisingly it worked 🙂

    So I guess the

    taxonomy-(insert your taxonomy here).php

    is equivalent to category.php

    and this
    single-(insert your taxonomy here).php

    is equivlant to single.php just the wordpress docs didn’t explain that good enough



    Has anyone tried this with custom permalinks? An associate mentioned he did get it to work but only with the default permalink turned on.



    yeah using the way i mentioned above worked with custom permalinks

    Rev. Voodoo’s solution worked like a champ. Stoked!!!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Taxonomy template file in custom theme’ is closed to new replies.