I've got a custom publish type with multiple taxonomy types. The problem is concentrated around one of them. I have to display all custom posts which have a taxonomy from featured-suppliers checked. At this time, there's only one "featured" , but there might be more later on, for example "highlight" or "sponsor" or something like that alone individuals lines. But, for the time being, I simply need to undergo all of the "suppliers" custom publish type, find ones with "featured" checked within the "featured-suppliers" taxonomy.

I've some some posts available that condition it isn't possible, however they were either from 2.8 or from the initial of the year and that i know WordPress has launched a minumum of one update since that time.

Thanks ahead of time!!

Query Custom Publish Types by Taxonomy Term

This sample will assume:

  • the custom publish type was registered using the taxonomy and also the taxonomy was registerd with 'query_var' =>true and 'hierarchial' => true

  • The "checked" term would be the parent and then any brand new ones could be added afterwards as children.

The Code:

 <?php query_posts( array( 'featured-vendors' => 'checked' ) ); ?>
    <?php if( is_tax() ) {
        global $wp_query;
        $term = $wp_query->get_queried_object();
        $title = $term->name;
    }  ?>

    <div class="my-custom-post">
    <h3><?php echo($title); ?></h3> //this will show the name of the post type
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

     <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 

    <div class="entry"> <h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>

        <?php the_excerpt(); ?> //shows the excerpt 

     </div><!--/end entry-->
</div><!--/end post-->

    <?php endwhile; else: ?>
    <p><?php _e('No Post Found','your_theme_text_domain'); ?></p> 

    <?php endif; ?>