Pagination for custom shop loop woocommerce
<p>I'm using custom shop loop on woocommerce archive-product page. And trouble is that i have one more extra empty page. This pagination work fine for blog, but not here. </p>

<pre><code>&lt;?php
                $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                $product = new WC_Product(get_the_ID());
                $params = array('posts_per_page' =&gt; 12, 'post_type' =&gt; 'product', 'paged' =&gt; $paged, 'tax_query' =&gt; array(
        array(
            'taxonomy' =&gt; 'product_cat',
            'field' =&gt; 'slug',
            'terms' =&gt; array( 'free' ),
            'operator' =&gt; 'NOT IN'
        )
    ));
                $wc_query = new WP_Query($params);
                ?&gt;
                &lt;?php if ($wc_query-&gt;have_posts()) : ?&gt;
                &lt;?php while ($wc_query-&gt;have_posts()) :
                $wc_query-&gt;the_post(); ?&gt;
                &lt;article class="portfolio__item portfolio__item--shop"&gt;
                    &lt;figure class="blog__image-container"&gt;
                        &lt;?php if ( has_post_thumbnail()) {the_post_thumbnail('thumb-blog' ,array("class"=&gt;"portfolio__image post_thumbnail"));} ?&gt;
                    &lt;/figure&gt;
                    &lt;h3 class="portfolio__content-title portfolio__content-title--shop"&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;
                    &lt;p class="portfolio__content-text portfolio__content-text--shop"&gt;&lt;?php $product = new WC_Product(get_the_ID()); echo $product-&gt;get_price_html(); ?&gt;&lt;/p&gt;
                        &lt;div class="portfolio__content"&gt;
                            &lt;img class="portfolio__content-image" src="&lt;?php echo get_template_directory_uri(); ?&gt;/img/link-loop.png" alt="" data-jslghtbx="&lt;?php
                                $thumb_id = get_post_thumbnail_id();
                                $thumb_url = wp_get_attachment_image_src($thumb_id,'thumb-big', true);
                                echo $thumb_url[0];
                            ?&gt;"&gt;
                            &lt;a href="?add-to-cart=&lt;?php echo $product-&gt;id; ?&gt;" class="portfolio__link"&gt;
                                &lt;p class="portfolio__content-text"&gt;Click to buy&lt;/p&gt;
                            &lt;/a&gt;
                        &lt;/div&gt;

                &lt;/article&gt;
                &lt;?php endwhile; ?&gt;
</code></pre>

<p>How i can fix this? <a href="http://wrap-design.com/portfolio/" rel="nofollow noreferrer">http://wrap-design.com/portfolio/</a>
And this is me code for pagination in function.php </p>

<pre><code>function wp_corenavi() {
  global $wp_query;
  $pages = '';
  $max = $wp_query-&gt;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 = 0; //1 - выводить текст "Страница N из N", 0 - не выводить
  $a['mid_size'] = 3; //сколько ссылок показывать слева и справа от текущей
  $a['end_size'] = 1; //сколько ссылок показывать в начале и в конце
  $a['prev_text'] = ''; //текст ссылки "Предыдущая страница"
  $a['next_text'] = ''; //текст ссылки "Следующая страница"

  if ($max &gt; 1) echo '&lt;div class="navigation"&gt;';
  if ($total == 1 &amp;&amp; $max &gt; 1) $pages = '&lt;span class="pages"&gt;Страница ' . $current . ' из ' . $max . '&lt;/span&gt;'."\r\n";
  echo $pages . paginate_links($a);
  if ($max &gt; 1) echo '&lt;/div&gt;';
}
</code></pre>