0

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(); ?>
  • Posts don't have taxonomies. They have terms that belong to taxonomies. If "Featured" is a taxonomy, which term is actually applied to posts? Or is "Featued" a term of another taxonomy, like category? – Jacob Peattie May 18 at 4:04
  • @JacobPeattie I've edited the question now I understand custom taxonomies better, but I still can't get it to work. – The Chewy May 18 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.