Display 1 custom post type by a custom taxonomy not working

Question

So the idea here is I have multiple products (CPT) and a custom taxonomy named Feature. It’s a radio button field with Yes/No option. I want to display 1 random featured product on front page. But somehow it didn’t work, what did I do wrong?

<?php 
                    $args = array(
                        'post_type' => 'product',
                        'orderby' => 'rand',
                        'posts_per_page' => 1,
                        'tax_query' => array(
                            array(
                                'taxonomy' => 'product_feature', //CPT Name
                                'field' => 'product_feature_field', //Field Name
                                'terms' => array( 'product-feature-yes' ) //Taxonomy Slug
                                ),
                            )
                        );
                    $new_query = new WP_Query( $args ); 
                ?>

0
Vy Nguyen 4 weeks 2021-04-11T01:40:58-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse