2016-11-03 3 views
-1

私はワオコマースのアーカイブ製品ページでカスタムショップループを使用しています。そして、問題は、余分な余分なページがもう1つあることです。このページ設定はブログではうまくいきますが、ここではできません。カスタムショップループワコムのページネーション

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

       </article> 
       <?php endwhile; ?> 

どうすれば修正できますか? http://wrap-design.com/portfolio/ そして、これはfunction.php

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

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

答えて

0

にページネーションのためのコードは私ですそれは奇妙だが、ワードプレスの設定にする場合 - 「最大でブログページショー」を読んで、私のループのすべてでpost_per_pageと同等の数が働いています)!