WordPress.org

Support

Support » How-To and Troubleshooting » Can you query multiple taxonomy’s in one call?

Can you query multiple taxonomy’s in one call?

  • I am trying to list custom posts by taxonomy with the taxonomy title then the posts underneath. It works fine but I have to make a new query for each taxonomy. It seems that there must be a way to include them all in one query. Here is the code I am using:

    <?php wp_reset_query(); ?>
    <?php query_posts( array( 'classification' => 'whiskey', ) ); ?>
    <?php if( is_tax() ) {
        global $wp_query;
        $term = $wp_query->get_queried_object();
        $title = $term->name;
    }  ?></p>
    <p><ul class="shelf-talkers">
    <span class="tax-title"><?php echo($title); ?></span>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?></p>
    
    <li><a class="zoom" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    <?php endwhile; else: ?>
    <?php endif; ?>
    </ul>

    This query is repeated around 20 times on my template. Any ideas on how to make one query that will give the same results?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can you query multiple taxonomy’s in one call?’ is closed to new replies.
Skip to toolbar