views:

149

answers:

1

On my site (currently PHP5, wordpress 2.8.5) I have a lot of categories total=150. Each category is a City name ie: Paris, this has a tag associated with this category. ie: Hotel, Sports, Bars, Entertainment, Food total->5

On my Archive page I'm looking to produce a tabbed section based on my tags. ie:

tab 1: tag->Hotel-> lists all the posts from Paris with the selected tag
tab 2: tag->Sports-> lists all the posts from Paris with the selected tag
tab 3: tag->Bars-> etc...etc..

After clicking a category linked to the archives page, the page is split into my 5 base sections, each of which would need a custom query applied to it to display the posts.

just now the page code looks like much the same as any default archives page.

$post = $posts[0];
if (is_category()) { ?>

    <h2 class="title"><?php single_cat_title(); ?></h2>
    <div style="border-bottom:1px dotted #ccc; text-align:justify;">
<?php echo category_description( $category ); ?>  
    <br />
    <br />  
    </div>  } // end if category

Tab 1:
<strong>Hotels</strong>
<?php query_posts('tag=hotels&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></div>
<div><?php the_excerpt(); ?></div>
<br />
<?php endwhile; endif; ?>

Tab 2:
<strong>Restaurants</strong>
<?php query_posts('tag=restaurants&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></div>
<div><?php the_excerpt(); ?></div>
<br />
<?php endwhile; endif; ?>

Just now the page loads, but each tab section will just list all posts, with the associated tag, and not filter through the category... so all posts from the tag hotel will be listed(well 5 of them ie: showposts=5),

So my question is this: Is there anyway that the category can be filtered then filtered again based on tag?

hopefully that's enough info for you Gurus out there. if not let me know.

Cheers

Marty

+1  A: 

Use the get_query_var to get the queried category,

if ( is_category() ) { $cat = get_query_var('cat');

then in your query, for example use,

query_posts('tag=hotels&showposts=5&cat='.$cat);

Michael
thanks a lot Michael. just what the doctor ordered ;)
Marty