Display Custom Post Type Based on Taxonomy With WP_Query()

Question

I would like to pull in 3 posts from a custom post type called ‘articles’ that have a ‘featured’ taxonomy.

I’m using the code below, but it isn’t pulling in just the posts with the ‘Featured’ taxonomy, and I can’t seem to get it work. The ‘Featured’ taxonomy is an additional taxonomy used with other taxonomies for this post type, but I wouldn’t think that would prevent the WP_Query() pulling in the ‘Featured’ taxonomy?

Any suggestions would be really welcome.

<?php 
    $homePageFeatured = new WP_Query(array(
        'posts_per_page' => 3,
        'post_type'=> 'articles',
        'tax_query' => array(
            array(
                'taxonomy' => 'Featured',
            ),
        )
    ));

    while(  $homePageFeatured->have_posts()){
            $homePageFeatured->the_post(); ?>

            <article>
                <!-- HTML FOR TAXONOMY  -->
            </article>

<?php } ?>
<?php  wp_reset_postdata(); ?>
0
, , The Chewy 4 years 2020-05-17T23:10:44-05:00 0 Answers 101 views 0

Leave an answer

Browse
Browse