第2页,等等404 Wordpress woocommerce

时间:2016-04-01 01:22:21

标签: php wordpress woocommerce

我不明白它错了吗? 当我点击第2页的分页时,它会抛出404我不知道为什么。

我正在使用woocommerce和wp-pagenavi插件,

先谢谢你。新手在这里

<?php
        $args = array(
          'post_type' => 'product',
          'paged' => get_query_var('paged')
        );
        $paged = (get_query_var('page')) ? get_query_var('page') : 1;
        $homepage_query = new WP_Query($args);
      ?>
      <?php //query_posts('posts_per_page=4&paged='.get_query_var('paged')); ?>
      <?php if ( have_posts() ) : ?>
        <?php while ( $homepage_query->have_posts() ) : $homepage_query->the_post(); ?>
         <div class="post-list-item">
            <div class="row no-gutters">
              <div class="col-lg-3 post-item-type">
                <i class="fa fa-file-text-o"></i>
                <a href="<?php the_permalink();?>"><button class="btn btn-green">View Document</button></a>
              </div>
              <div class="col-lg-9 post-item-panel">
                <div class="post-title">
                    <span><?php the_title();?></span>
                </div>
                <div class="post-excerpt">
                  <p><?php echo substr(get_the_excerpt(), 0,160); printf( '<a class="read-more" href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( ' ...Read More', 'textdomain' )
    ); ?></p>
                </div>
              </div><!--//post-item-panel-->
            </div><!--row-no-gutters-->
          </div><!--//post-list-item-->



<?php endwhile;  wp_pagenavi(array( 'query' => $homepage_query )); ?><?php endif;  ?>

1 个答案:

答案 0 :(得分:0)

没关系,

解决了! :)

  <?php

        $args = array(
          'post_type' => 'product',
          'paged' => get_query_var('paged')
        );

        $homepage_query = new WP_Query($args);   
              $paged = get_query_var('paged') ? get_query_var('paged') : 1;

         ?>
            <?php if (have_posts() ) : while ($homepage_query->have_posts() ) : $homepage_query->the_post(); ?>

           <div class="post-list-item">
            <div class="row no-gutters">
              <div class="col-lg-3 post-item-type">
                <i class="fa fa-file-text-o"></i>
                <a href="<?php the_permalink();?>"><button class="btn btn-green">View Document</button></a>
              </div>
              <div class="col-lg-9 post-item-panel">
                <div class="post-title">
                    <span><?php the_title();?></span>
                </div>
                <div class="post-excerpt">
                  <p><?php echo substr(get_the_excerpt(), 0,160); printf( '<a class="read-more" href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( ' ...Read More', 'textdomain' )
    ); ?></p>
                </div>
              </div><!--//post-item-panel-->
            </div><!--row-no-gutters-->
          </div><!--//post-list-item-->


            <?php endwhile; endif; ?>
            <?php
              if ( function_exists('wp_bootstrap_pagination') )
              wp_bootstrap_pagination();
            ?>