sslion
Форумчанин

На странице "Скидки и акции" у меня выводятся товары имеющие скидку.
http://beregitechudo.ru/aktsii/
Однако при переходе страницами пагинации, отображаются все равно товары первой страницы.
Вот код который формирует страницу "Акции"
Может где-то нужно что-то еще прописать? Например в параметрах WP_Query?
http://beregitechudo.ru/aktsii/
Однако при переходе страницами пагинации, отображаются все равно товары первой страницы.
Вот код который формирует страницу "Акции"
PHP:
<?php get_header(); /* Template Name: Sales */
$cat = isset($_GET['cat']) ? filter_input(INPUT_GET, 'cat') : '';
$product_ids_on_sale = wc_get_product_ids_on_sale();
?>
<main class="main-content cf contacts">
<div class="container">
<div class="breadcrumbs">
<?php if (function_exists('yoast_breadcrumb')) yoast_breadcrumb('<div class="breadcrumbs__inner">', '</div>'); ?>
<h2 class="page-title"><?php the_title(); ?></h2>
</div>
<table>
<tr>
<td style="vertical-align:top;padding:5px;">
<?php
$taxonomy = "product_cat";
$terms = get_terms($taxonomy, array(
"orderby" => "count",
"hide_empty" => true
)
);
$hierarchy = _get_term_hierarchy($taxonomy);
foreach($terms as $term)
{
if($term->parent) { continue; }
if($hierarchy[$term->term_id])
{
if($term->slug == "dlya-detej")
{
echo "<span style='font-size:31px;color:#00a4df;'>Для детей</span>";
}
if($term->slug == "dlya-mam")
{
echo "<span style='font-size:31px;color:#00a4df;'>Для мам</span>";
}
echo "<ul class='drop_vert_menu'>";
foreach($hierarchy[$term->term_id] as $child)
{
$child = get_term($child, "product_cat");
$aktsii = "";
$slug = $child->slug;
$term_link = get_term_link($child->term_id);
if($slug != "skidki-i-aktsii") {
?>
<li><a href="<?php echo "?cat=".$slug; ?>"><?php echo $child->name ?></a><?php
$childs_of_child_ids = get_term_children($child->term_id, "product_cat");
if(count($childs_of_child_ids) == 0)
{
continue;
}
?><ul ><?php
foreach($childs_of_child_ids as $child_of_child_id)
{
$child_of_child = get_term($child_of_child_id, "product_cat");
$term_link = get_term_link($child_of_child->term_id);
if($child_of_child->parent == $child->term_id)
{
?><li><a href="<?php echo "?cat=".$child_of_child->slug; ?>"><?php echo $child_of_child->name ?></a></li><?php
}
}
?></ul>
<?php
}
?></li><?php
}
?>
</ul>
<?php
}
}
?>
</td>
<td style="vertical-align:top;padding:5px;">
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php
$args = array(
'post_type' => 'product',
'post_status ' => 'publish',
//'category_name' => 'podguzniki',
'product_cat' => $cat,
'posts_per_page' => 20,
'post__in' => array_merge( array( 0 ), $product_ids_on_sale )
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
$price = intval(get_post_meta( get_the_ID(), '_regular_price', true));
$sale = intval(get_post_meta( get_the_ID(), '_sale_price', true));
$difference = $price - $sale;
$discount = intval($difference/$price*100); ?>
<div class="swiper-slide">
<div class="img-wrap">
<a href="<?php the_permalink(); ?>">
<img src="<?php echo the_post_thumbnail_url(); ?>" alt="">
</a>
</div>
<div class="title"> <a href="<?php the_permalink(); ?>"><?php echo the_title('','',false); ?> </a></div>
<?php global $product; ?>
<? if($product->product_type != "variable"){ ?>
<? if($sale) : ?>
<div class="price">
<span class="old-price"><?php echo $price; ?> ₽</span>
<?php echo $sale; ?> ₽
</div>
<?php else : ?>
<div class="price"><?php echo $price; ?> ₽</div>
<?php endif; ?>
<? }
?>
<? if($product->product_type == "variable"){
woocommerce_variable_add_to_cart(); ?>
<a href="" onclick="forms['add_to_cart_form_<?=get_the_ID();?>'].submit()" class="buy">Купить<span class="basket"></span></a>
<? } else { ?>
<a href="<?php echo $product->add_to_cart_url(); ?>" class="buy">Купить<span class="basket"></span></a>
<? } ?>
<?php //woocommerce_template_loop_add_to_cart(); ?>
<?php if($sale) : ?>
<div class="discount-notify">Скидка<span class="discount-size"><?php echo ceil($discount); ?>%</span></div>
<?php endif; ?>
</div>
<?
endwhile;
} else {
echo __( 'Продуктов не найдено' );
}
wp_reset_postdata();
?>
<?php if(get_field('description')) { ?><div class="page-description">
<?php the_field('description'); ?>
</div><?php } ?>
</td>
</tr>
</table>
</div>
</main>
<?php
woocommerce_product_loop_end();
wp_pagenavi(array( 'query' => $loop ));
get_footer();
?>