Support

Account

Home Forums General Issues Post type = product per single product Reply To: Post type = product per single product

  • Hi Jhon,

    appreciate the reply! The code above is coming from woocommerce/content-single-product.php

    Basically there is an ACF field called featured_products that is displayed on the each product page while creating/editing a product. This would be so we can select what products we want to feature for the current product.

    With your help I have resolved the issue in the code previous developer had done.

    I amended the code and left out the following:

     <!--  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'      => 4,
                    'meta_query'          => $meta_query,
                    'tax_query'           => $tax_query,
                );
                 -->

    Then edited the code below this to reflect

    <?php
                    $post_objects = get_field( 'featured_products' );
                       
                    
    			if( $post_objects ): ?> 
    

    while adjusting the code within the divs.

    THANK YOU SO MUCH! I would never have gotten this without your suggestion (and some heavy reading in the documentation!)