Display Custom Post Type Based on Taxonomy With WP_Query()
-
Hi,
I would like to pull in 3 posts from a custom post type called ‘articles’ that have a ‘Featured’ custom taxonomy term.
I’m using the code below, but it isn’t pulling in just the posts with the ‘Featured’ taxonomy term, and I can’t seem to get it work.
The ‘Featured’ taxonomy term is an additional taxonomy term used with other taxonomies terms for this post type (i.e a post could have the taxonomy terms ‘Featured’ and ‘SEO’).
Any suggestions would be really welcome.
<?php $homePageFeatured = new WP_Query(array( 'posts_per_page' => 3, 'post_type'=> 'articles', 'tax_query' => array( array( 'taxonomy' => 'articles_categories', 'terms' => 'Featured', ), ) )); while( $homePageFeatured->have_posts()){ $homePageFeatured->the_post(); ?> <article> <!-- HTML FOR TAXONOMY --> </article> <?php } ?> <?php wp_reset_postdata(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display Custom Post Type Based on Taxonomy With WP_Query()’ is closed to new replies.