Home › Forums › General Issues › Post type = product per single product › Reply To: Post type = product per single product
The code is working exactly as you describe and it seems that is what it is meant to do.
The first part
<?php
$meta_query = WC()->query->get_meta_query();
$tax_query = WC()->query->get_tax_query();
$tax_query[] = array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN',
);
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'orderby' => 'post_date',
'order' => 'DSC',
'posts_per_page' => 1,
'meta_query' => $meta_query,
'tax_query' => $tax_query,
);
?>
<div class="row">
<?php
$featured_query = new WP_Query( $args );
This is getting a 1 product that has the “visibility” taxonomy term of “feature_product” set. This will always get the same post. The the rest of the code is getting the featured product as set on this product.
I don’t know where your code is running or in what template, but the above code should likely be removed and somewhere in the single product template you should be getting the fields from the current product being shown rather than the above. The code you posted would be useless for doing this and if that’s not what should be happening should probably all be removed.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.