L
L
Lord_Dantes2019-02-04 17:02:47
WordPress
Lord_Dantes, 2019-02-04 17:02:47

Any Wordpress pagination not working?

Good day.
I have a regular blog.
And the usual posts are nothing more. And I need a simple pagination.
I tried the_posts_pagination(), didn't work. I tried the WP-Paginate plugin too, nothing.
Perhaps I'm not doing something right? Code below.

<?php $args = array( 'post_type' => 'blog', 'posts_per_page' => 1 ); $loop = new WP_Query( $args ); ?>
      <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <div class="col-md-4">
          <div class="blog-item_box">
            <div class="blog-item_img-box"><img src="<?php the_field('img_blog-item') ?>" alt=""></div>
            <div class="blog-item_title"><?php the_content(); ?></div>
            <div class="blog-item_info"><?php the_excerpt(); ?></div><a class="blog-item_details-info" href="<?php the_permalink(); ?>">Узнать подробнее</a>
          </div>
        </div>
      <?php endwhile; ?>
          <?php the_posts_pagination(); ?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
tyzberd, 2019-02-04
@tyzberd

try
either this https://wp-kama.ru/function/wp_reset_query
or https://wp-kama.ru/function/wp_reset_postdata

J
Jupiter Max, 2019-02-04
@vardoLP

replace this
with this
the_posts_navigation();

P
Pavel Chesnokov, 2019-02-04
@cesnokov

<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array( 'post_type' => 'blog', 'posts_per_page' => 1, 'paged' => $paged ); 
$loop = new WP_Query( $args );
?>
      <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <div class="col-md-4">
          <div class="blog-item_box">
            <div class="blog-item_img-box"><img src="<?php the_field('img_blog-item') ?>" alt=""></div>
            <div class="blog-item_title"><?php the_content(); ?></div>
            <div class="blog-item_info"><?php the_excerpt(); ?></div><a class="blog-item_details-info" href="<?php the_permalink(); ?>">Узнать подробнее</a>
          </div>
        </div>
      <?php endwhile; ?>
          <?php the_posts_pagination(); ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question