Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom page "fine-art", which lists the different types of fine art that we produce based on the custom-taxonomy "fine_art_category". Some of the custom taxonomies are wood, metal, Fine Art Editions/Album, Fine Art Editions/Metal.

The Fine Art Editions taxonomy doesn't have anything in it, it only has subcategories Album and Metal.

Is it possible to create a slug for each of the custom taxonomies, so for example http://www.com/fine-art/wood and http://www.com/fine-art/metal. And in each page lists all of the posts with the custom taxonomy of wood. Or do I need to create a custom page for each category to make this happen?

This is my custom page for fine-art, which just lists the last five posts in each custom taxonomy.

<?php
/*
Template Name: Beta Fine Art
*/

$terms = get_terms("fine_art_category");
$count = count($terms);
if ( $count > 0 ){
foreach ( $terms as $term ) {
echo "<h3>" . $term->name . "</h3>"; 


$args = array(
    'post_type' => 'fine-art',
    'posts_per_page' => 5,
    'tax_query' => array(
        array(
            'taxonomy' => 'fine_art_category',
            'field' => 'slug',
            'terms' => $term->slug
        )
    )
);

$wp_fineart_query = new WP_Query( $args );

while( $wp_fineart_query->have_posts() ) : $wp_fineart_query->the_post(); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php
endwhile;
}
}
?>
share|improve this question
    
It may help you to clarify that "fine_art_category" is your taxonomy, and "wood", and "metal" are terms of that taxonomy. You may find this post helpful: WordPress Archive Pages Based on Custom Taxonomy as well as the codex documentation on Template Hierarchy. –  Evan Mattson May 9 '12 at 20:54

1 Answer 1

WordPress already does all this by default. There is not reason for you to need to modify the slugs work, you just need to configure your custom taxonomy to have the rewrite slug 'fine-art'.

I think you can then just create your page with that same 'fine-art' slug. I believe it should still find that page regardless of the taxonomy name having the same slug. Then all you need to do in your template is what you appear to already be doing, which is generate the links for the terms you want to show.

If this still is not working, it might be helpful for you to include your custom taxonomy declaration.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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