I have the following code snippet to retrieve all products with the ACF field for display, but I only get 148 products back. However, I have 800 products with the ACF field
function display_all_woocommerce_products() {
$products = wc_get_products( array(
'status' => 'publish',
'limit' => -1
) );
if ( $products ) {
foreach ( $products as $product ) {
$sp_model = get_field( 'sp_model', $product->get_id() );
if ( $sp_model ) {
echo '<p>SP Model: ' . $sp_model . '</p>';
}
}
} else {
echo 'No product';
}
}add_shortcode( 'display_all_products', 'display_all_woocommerce_products' );