the story: I use wordpress to build my site with 3 categories "red", "green", "blue" and registered custom taxonomy "products" that includes some taxonomies like "pen" etc., I created a template "taxonomy-products.php" to display taxonomies of "products". The slug should be: www.mysite.com/products/pen.

I wanna add the categories to the taxonomy, it means when visit - for example - www.mysite.com/products/pen/red, the site will load "taxonomy-products.php" to display and query the pens in category "red"...

My inspiration - add something in "taxonomy-products.php" like:

<?php if ( "www.mysite.com/products/pen/" || "www.mysite.com/products/pen/red" ) : ?>
        <?php locate_template( array( 'red.php' ), true ) ?>

    <?php elseif ( "www.mysite.com/products/pen/blue" ) : ?>
        <?php locate_template( array( 'blue.php' ), true ) ?>

    <?php elseif ( "www.mysite.com/products/pen/green" ) : ?>
        <?php locate_template( array( 'green.php' ), true ) ?>

    <?php endif; ?>

In "red.php", "blue.php" and "green.php" will query corresponding pens ...

Can anybody help me to figure out the coding job? thanks in advance...

link|improve this question
feedback

1 Answer

The answer might be this... Taxonomy Templates. Simply name your template as taxonomy-products-blue.php or taxonomy-products-green.php. Make sure the slugs for terms blue and green are right.

link|improve this answer
Thanks, Rutwick, but it is not working, coz red, green and blue are categories, not belong to "products" taxonomy. – user11501 Dec 29 '11 at 10:50
Ohh... Apologies for misunderstanding... You'll need to write a custom rewrite rule for this. – Rutwick Gangurde Dec 30 '11 at 16:56
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.