Support

Account

Home Forums General Issues Relationship Field on single-cpt.php Reply To: Relationship Field on single-cpt.php

  • Hi @seasterling

    You should be able to check if the current product loop is the same as the current product page like this:

    // Get the current product page ID
    $current_product_id = get_the_ID();
    
    foreach( $products as $product ):
    
        // Skip if the current product is listed
        if( $current_product_id == $product->ID ){
            continue;
        }
    
        $relatedImages = get_field('images', $product->ID);
        // Rest of the code here
        
    endforeach;

    I hope this helps 🙂