A
A
Anonimmus2021-03-18 02:01:52
WordPress
Anonimmus, 2021-03-18 02:01:52

How to display products with pagination in the taxonomy-product.php file?

Hello, could you tell me or share the code. I can display products with a simple request, but columns and quantities are usually regulated there, but I don’t know how to connect woocomerce pagination to it. I hope any option will do, the main thing is that pagination be

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anonimmus, 2021-03-18
@Anonimmus

Comrades, save

<section class="section recommendations similar">
  <div class="container recommendations_container">	
    <div class="content" style="padding: 0 15px;">
          <div class="section_header">
            <div class="recommendations_items">
<?php 
$related = wc_get_related_products($product->get_id());
$loop = new WP_Query( array( 

  'post_type'				=> 'product',
  'ignore_sticky_posts'	=> 1,
  'posts_per_page'		=> 99,
  'columns'				=> 3,
  'order'					=> 'rand',
  'post__in'				=> $related,
  'post__not_in'			=> array($product->get_id())
  )); 

  while ( $loop->have_posts() ): $loop->the_post(); ?>
  	<div class="recommendation">



  <div <?php post_class("inloop-product"); ?>>
    <div class="row">
      <div class="col-sm-4">
        <?php the_post_thumbnail("thumbnail-215x300"); ?>
      </div>
      <div class="col-sm-8">
        <h4>
          <a href="<?php the_permalink(); ?>">
            <?php the_title(); ?>
          </a>
        </h4>
        <?php the_content(); ?>
        <p class="price">
          <?php _e("Price:","examp"); ?>
          <?php woocommerce_template_loop_price(); ?>
        </p>
        <?php woocommerce_template_loop_add_to_cart(); ?>
      </div>
    </div>
  </div> 


</div>
  <?php endwhile; ?>
   <?php if (function_exists('wp_corenavi')) wp_corenavi(); ?>

</div>
</div>
</div>
  </div>
</section>

functions.php
// для навигации на страницу объектов 
function wp_corenavi() {  
  global $wp_query, $wp_rewrite;  
  $pages = '';  
  $max = $wp_query->max_num_pages;  
  if (!$current = get_query_var('paged')) $current = 1;  
  $a['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));  
  $a['total'] = $max;  
  $a['current'] = $current;  
   
  $total = 1; //1 - ВЫВОДИТЬ ТЕКСТ "СТРАНИЦА N ИЗ N", 0 - НЕ ВЫВОДИТЬ  
  $a['mid_size'] = 2; //СКОЛЬКО ССЫЛОК ПОКАЗЫВАТЬ СЛЕВА И СПРАВА ОТ ТЕКУЩЕЙ  
  $a['end_size'] = 1; //СКОЛЬКО ССЫЛОК ПОКАЗЫВАТЬ В НАЧАЛЕ И В КОНЦЕ  
  $a['prev_text'] = 'Назад'; //ТЕКСТ ССЫЛКИ "ПРЕДЫДУЩАЯ СТРАНИЦА"  
  $a['next_text'] = 'Дальше'; //ТЕКСТ ССЫЛКИ "СЛЕДУЮЩАЯ СТРАНИЦА"  
   
  if ($max > 1) echo '<div class="paginator">';  
  if ($total == 1 && $max > 1) $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>'."\r\n";  
  echo $pages . paginate_links($a);  
  if ($max > 1) echo '</div>';  
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question