S
S
Sergey Volkov2021-06-22 10:24:49
PHP
Sergey Volkov, 2021-06-22 10:24:49

Why is pagination not working with WP_query?

Hello.

I'm trying to display pagination for posts on the page.php page.

<?php
   <!-- параметры для пагинации -->
   $args = [
      'base'         => '%_%',
      'format'       => '?page=%#%',
      'total'        => 1,
      'current'      => 0,
      'show_all'     => False,
      'end_size'     => 1,
      'mid_size'     => 2,
      'prev_next'    => True,
      'prev_text'    => __('« Previous'),
      'next_text'    => __('Next »'),
      'type'         => 'plain',
      'add_args'     => False,
      'add_fragment' => '',
      'before_page_number' => '',
      'after_page_number'  => ''
   ];



   global $wp_query;
   $query = new WP_Query( [
      'cat'            => '0',
      'posts_per_page' => '0'
         ] );

   while ($query->have_posts()) {
      $query->the_post();
      ?>

      <!-- HTML -->

      <?php
   }

   echo paginate_links( $args )
?>


I tried to display using the_posts_pagination, get_the_post_pagination, but it does not work.
I would be very grateful if you could help me with the problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question