Нужно $product_ids передать функции repeater_dynamic_query().
// The query
$products = new WP_Query( array(
'post_type' => array('product'),
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'pa_aktsiya',
'field' => 'slug',
'terms' => array('spetspredlozheniya'),
'operator' => 'IN',
),
array(
'taxonomy' => 'product_visibility',
'terms' => array( 'exclude-from-catalog' ),
'field' => 'name',
'operator' => 'NOT IN',
) )
) );
// The Loop
if ( $products->have_posts() ): while ( $products->have_posts() ):
$products->the_post();
$product_ids[] = $products->post->ID;
endwhile;
wp_reset_postdata();
endif;
function repeater_dynamic_query( $query ) {
if ( $query->query['post_type'][0] == 'product' ) {
$query->set( 'post__in', $product_ids );
$query->set( 'no_found_rows', true );
}
}
add_action( 'pre_get_posts', 'repeater_dynamic_query' );