Creating an Archive using a Custom Taxonomy

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:

Read More

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!

Related posts

Leave a Reply

2 comments

  1. 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));
    
  2. +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');