'product', 'post_status' => array('publish'), 'posts_per_page' => 12, // 12 товаров на страницу 'paged' => $paged, // Учитываем пагинацию 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => array(719, 567, 713), 'operator' => 'IN', ), ), ); $products = new WP_Query($args); while ($products->have_posts()) { $products->the_post(); global $product; $product_type = $product->get_type(); if (!in_array($product_type, array('subscription', 'subscription_variation', 'variable-subscription'))) { wc_get_template_part('content', 'product'); } } wp_reset_postdata(); die(); } $loc = pll_current_language(); if ($loc == 'en') { get_header('gp_eng'); } else { get_header('gp'); } // Определение, является ли страница магазином или имеет ID 18164 $is_shop_page = is_shop() || get_queried_object_id() == 18164; // Настройка запроса для страницы магазина if ($is_shop_page) { $args = array( 'post_type' => 'product', 'post_status' => array('publish'), 'posts_per_page' => -1, // Ограничиваем до 12 товаров на первой загрузке 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, // Учитываем пагинацию 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => array(719, 567, 713), 'operator' => 'IN', ), ), ); $products = new WP_Query($args); $p_count = $products->found_posts; // Всего товаров в запросе } else if (is_product_category()) { // Для страниц категорий $current_category = get_queried_object(); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, // Можно оставить -1, если пагинация не нужна для категорий 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $current_category->term_id, ), ), ); $products = new WP_Query($args); $p_count = $products->found_posts; } else { // Для других страниц $p_count = wc_get_loop_prop('total', 0); } ?>

have_posts()) { woocommerce_product_loop_start(); while ($products->have_posts()) { $products->the_post(); global $product; $product_type = $product->get_type(); if (!in_array($product_type, array('subscription', 'subscription_variation', 'variable-subscription'))) { wc_get_template_part('content', 'product'); } } woocommerce_product_loop_end(); wp_reset_postdata(); } else if (is_product_category() && $products->have_posts()) { woocommerce_product_loop_start(); while ($products->have_posts()) { $products->the_post(); global $product; $product_type = $product->get_type(); if (!in_array($product_type, array('subscription', 'subscription_variation', 'variable-subscription'))) { wc_get_template_part('content', 'product'); } } woocommerce_product_loop_end(); wp_reset_postdata(); } else if (wc_get_loop_prop('total') > 0) { woocommerce_product_loop_start(); while (have_posts()) { the_post(); global $product; $product_type = $product->get_type(); if (!in_array($product_type, array('subscription', 'subscription_variation', 'variable-subscription'))) { wc_get_template_part('content', 'product'); } } woocommerce_product_loop_end(); } else { ?>
coming soon
This item is not on our website yet, but it will be here very soon
get('paged') ? $products->get('paged') : 1; $max_pages = $products->max_num_pages; // Максимальное количество страниц из WP_Query ?>