You have to create a custom page template.
1. Create an php file on your theme directory by coping the page.php
2. Add <?php /* Template Name: Fishing */ ?>
at the top of the template.
3. Add <?php query_posts('category_name=fishing'); ?>
just above the loop i.e. <?php if(have_posts()) while ...
.
Read more here: http://codex.wordpress.org/Function_Reference/query_posts#Category_Parameters
That works okay for a couple of activities and locations, but I have several of each and want to produce pages with useful titles on each of the combinations, including groupings of activities for a location (e.g., Fishing and Hunting in BC).
I understand that get_query_var(‘tag’) in archive.php will return ‘fishing+bc’ from the query generated by ‘http://domain.com/category/fishing+bc’. I would like to explode this to get the individual tags, then get the tag names that go with the tag slugs and combine the names in a way that makes sense as a page title.
If I have the tag slugs from get_query_var(‘tag’), how do I get the tag names?
I eventually came up with the following which works for my limited application. My activity specific tags are all named like “Fishing in Canada” with slugs like “fishing”. My location specific tags are all named like “Activities in British Columbia” with slugs like “bc”. When I call archive.php using two tags (e.g., “fishing+bc”) the following code finds the 2 tags names and joins them back together as “Fishing in British Columbia”. The code bypasses situations where there is only one tag in the query. The code does not handle “bc+fishing” just “fishing+bc”. With 20 or so activities and 10 provinces, this is easier than coding a separate page for each combination.
$page_title = wp_title('', false);
$tags = get_query_var('tag');
$tag = explode(' ',$tags);
if (count($tag)>1) {
$tag_name = get_tags(array('slug'=>$tag[0]));
$page_title = str_replace(' in Canada','', $tag_name[0]->name);
$tag_name = get_tags(array('slug'=>$tag[1]));
$page_title .= str_replace('Activities','', $tag_name[0]->name);
}
Not very elegant but it works.