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;?>"> </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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.