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 recently adjusted the twentyten theme to display archives in a three column grid. In doing so, it seems that the archive has lost the ability to display posts from the specified taxonomy.

For instance, a taxonomy type is 'Flowers', with a specific flower being 'Rose'. When the 'Rose' archive is displayed, it simply lists all posts. I believe I have narrowed the problem to this line:

query_posts('cat=0&posts_per_page=12&paged='.$paged);

I understand that it is just listing all 'uncategorized' posts, but I am at a loss with how to have display a specific taxonomy archive as would normally be done for a category archive.

Any ideas? I am guessing it isn't as hard as I am making it, but I have searched for hours with no luck.

Thanks in advance!

share|improve this question
1  
Try just removing the line. –  Milo May 10 '11 at 21:42

2 Answers 2

up vote 4 down vote accepted

you can add the current term to you query so if its category, tag or custom taxonomy you will get the posts with the current term, try changing this:

query_posts('cat=0&posts_per_page=12&paged='.$paged);

with this:

$term_slug = get_query_var( 'term' );
$taxonomyName = get_query_var( 'taxonomy' );
query_posts(array('posts_per_page' => 12, 'paged' => $paged, $taxonomyName => $term_slug));
share|improve this answer
    
Wow, thanks much! That worked like a charm. –  Stephen S. May 10 '11 at 23:11

+1 to Milo answer. But if you need to change the post_per_page parameter, try this:

global $query_string;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts($query_string.'&paged='.$paged.'&posts_per_page=12');
share|improve this answer
    
I understood that you needed archive for a custom post type, not a taxonomy. Sorry! –  MZAweb May 11 '11 at 1:48

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.