I want to make pagination when selecting a category:

cx80363-wordpress.tw1.ru/category/toys/ 

Sample code running on category.php :

 <?php query_posts(array( 'cat' => 1, 'paged' => 1, 'post_per_page' => '1' )); if ( have_posts() ) while (have_posts()) : the_post(); ?> /* Посты */ <?php endwhile; ?> <?php the_posts_pagination(); ?> 

The page navigation itself displays, but nothing happens when you try to navigate.
What am I doing wrong?
WP 4.9.2
The template is self-written.

    1 answer 1

    Not so you do only one thing, you just take and display all the posts. When you go to navigation, you pass the page number in order to get the first post that should be displayed on the page, multiply the page number by the number of posts that should be displayed on the page. Thus you can display the necessary number of posts starting from the current one. This is done in a cycle

     for($i=$page*$postPerPage; $i<$page*$postPerPage+$postPerPage; $i++) printPost($i); 

    To realize this, you need to understand what cycles are, arrays and how to work with them.

    • $page*$postPerPage - never write anything like this in cycles, so puhe makes miscalculations at every iteration - DaemonHK
    • Well, let him do it, it's a trifle. - Profesor08