Home › Forums › General Issues › Post type = product per single product › Reply To: Post type = product per single product
Basically, you would delete the custom query and it’s associated loop and you would only need the code that starts with
$post_objects = get_field('featured_products');
and the loop associated with this field.
This would show posts associated with the current product.
You would keep this, but it may need some adjustments
$post_objects = get_field('featured_products');
if( $post_objects ): ?>
<div>
<h1>You may also like</h1>
<?php foreach( $post_objects as $post_object): ?>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_object->ID ), 'single-post-thumbnail' ); ?>
<div class="single-feature">
<a href="<?php echo get_the_permalink($post_object->ID); ?>" class="img-feature">
<img src="<?php echo $image[0];?>">
</a>
<div class="product-title-price">
<a href="<?php echo get_the_permalink($post_object->ID); ?>">
<h3><?php echo get_the_title($post_object->ID); ?></h3>
</a>
<?php echo $price; ?>
</div>
</div>
</div>
<?php endforeach;
endif;
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’re working hard on Advanced Custom Fields PRO 6.0, and Beta 1 is now available 🚀
— Advanced Custom Fields (@wp_acf) August 12, 2022
Featuring improved performance for Repeater fields with large datasets, and a new generation of ACF Blocks.
Let’s take a look 🧵https://t.co/Befre3kFAo
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.