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 registered 2 taxonomies: festival_year and art_genre. I would like users to search for a specific year and genre but am not sure the best way to do this. I have tried various plugins but none have worked. I was able to create separate files, like taxonomy-art_genre-consumable-crafts.php with the following code:

<?php
$festivalquery = wp_parse_args($query_string);
$festivalquery['tax_query'] = array(
    'showposts' => 10 ,
    'orderby' => 'title',
    'order' => 'ASC',
    'paged' => $paged,
    'relation' => 'AND',
    array(
        'taxonomy' => 'festival_year',
        'terms' => array('2010-artists'),
        'field' => 'slug',
    ),
    array(
        'taxonomy' => 'art_genre',
        'terms' => array('consumable-crafts'),
        'field' => 'slug',
    ),
);
query_posts($festivalquery);
?>

which gives me the query I'm looking for. However, there are 11 genres (and of course there will be multiple years).

Instead of creating separate page templates, what is the best way to accomplish this?

The test site: http://www.beta.cornhillartsfestival.com/artists/

Thank you so much!

share|improve this question

1 Answer 1

First, to make sure I understand the general premise, are you wanting to know how to avoid making a separate template for each genre and year?

So, for example, I click a link to view the "consumable crafts" genre. It loads up all the consumable crafts.

Now, if you're wanting to just make a "genre" template, for instance "taxonomy-art_genre.php", then what you want is to create that file, pull in your query, and replace:

'terms' => array('consumable-crafts'),

With:

'terms' => get_query_var( 'term' )

That will load the term, as a slug, based on the term their viewing. Thus, going to http://www.beta.cornhillartsfestival.com/art_genre/consumable-crafts/ would load taxonomy-art_genre.php and the "term" that get_query_var would return is "consumable-crafts".

Does that make sense?

Now, are you wanting to have a page that will show you a particular genre in a particular year? That's a bit of a different animal, but it can also be solved.

Let me know if this is the answer you were looking for.

share|improve this answer
    
Thank you for answering! Yes, I want to be able to show a particular genre in a particular year. On the 2010 page I would also like to have a tag cloud or list of the art genres and when one clicks on a tag they are taken to 2010 - glass artists, etc. Is this possible? Thank you! –  ellaj May 25 '11 at 11:24
    
@ellaj - In order to advise on the first part, I need a better sense of how they would get to a page that shows a particular genre in a particular year. Could you advise me on that? –  Jonathan Wold May 26 '11 at 15:05
    
@ellaj - Ok, so if I'm understanding, you basically want to have a page of 2010 artists. On the side, you might have a heading that said "Other genres in 2010", and it would list them underneath - clicking on one of those would take you to a page that showed, for instance, "Glass Artists in 2010". Now, on that page, are you also wanting to show a link to "Glass Artists in 2011", etc? Let me know if I'm getting the right picture. –  Jonathan Wold May 26 '11 at 15:10

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.