简体   繁体   中英

Page navigation not working wordpress

So this is driving me kind of crazy, I just can't seem to get the page navigation to work. I installed a plugin wp-pagenavi but it still doesn't work. Is there anyone that could help me getting it to work. Here is my code (the loop):

<?php $args = array(
            'post_type' => 'portfolio',
            'posts_per_page'=> 10,
            'orderby' => 'ID',
            'order' => 'DESC',
            'tax_query' => array(
                array(
                'taxonomy' => 'foto_video_type',
                'field' => 'slug',
                'terms' => 'foto'
                        )
                    )
                );

                $products = new WP_Query( $args );
                    if( $products->have_posts() ) {
                        while( $products->have_posts() ) {
                            $products->the_post();
        ?>

        <?php   $naam =     get_field('naambedrijf');
                $soort =    get_field('soort_uitje');
                $foto =     get_field('flickr_fotoset'); ?>

            <div class="col s12">
                    <div class="title">
                        <h2 class="truncate" style="line-height:20px;"><?php echo $naam; ?>&nbsp;|&nbsp;<?php echo $soort; ?></h2>
                            <a class="fotos" href="https://www.flickr.com/photos/../sets/<?php echo $foto; ?>" target="_blank"><small>Bekijk alle foto's</small></a>
                    </div>
                    <div class="flickrphotoset">
                        <?php echo do_shortcode('[slickr-flickr id="" search="sets" set="' . $foto . '" size="large" items="9" bottom="10" responsive="on" type="thumbnail" galleria_options="lightbox:true;thumbnail:lazy"]'); ?>
                    </div>
            </div>



        <?php
            }
                }
                    else {
                        echo 'There seems to be a problem, please try searching again or contact customer support!';
                    } ?>

<?php wp_pagenavi(); ?>

And this is my archive code:

<section id="collaps">
  <div class="row">
    <div class="col s12 offset-s0 m12 l7 offset-l5">
      <ul class="collapsible z-depth-1" data-collapsible="accordion">
          <li>
            <div class="collapsible-header"><i class="fa fa-camera" aria-hidden="true"></i><p>Foto</p></div>
              <div id="portfolio" class="collapsible-body">
                <div class="row">
                 <?php get_template_part('loop-foto'); ?>
                  <div class="col s12">

                    </div>
                  </div>
                </div>
          </li>
          <li>
            <div class="collapsible-header"><i class="fa fa-video-camera" aria-hidden="true"></i><p>Video</p></div>
              <div id="portfolio" class="collapsible-body">
                <div class="row">
                 <?php get_template_part('loop-video'); ?>
                </div>
              </div>
          </li>     
      </ul>
    </div>
  </div>
</section>

When i add the "older" Wordpress code:

<div class="navigation">
 <div class="alignleft"><?php next_posts_link('&laquo; Older Entries', '1000') ?></div>
 <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;', '1000') ?></div>
</div>

It kind of works. But page/2/ give a 404 error... What am I doing wrong?

I'm not sure if it is your case, but as I faced a similar case, I'm going to post my solution here:

In my case the problem was that I had a page with a permalink equal to the post type, so just changing the page slug solved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM