Answer the question
In order to leave comments, you need to log in
How to make pagination in Wordporess?
I want to make pagination when selecting a category. ( cx80363-wordpress.tw1.ru/category/toys/)
Sample code working 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(); ?>
Answer the question
In order to leave comments, you need to log in
As a result, I decided to get the page number using WP.
The code is like this:
<?php $pageNum=(get_query_var('paged')) ? get_query_var('paged') : 1; //получаем текущую страницу
query_posts(array(
'cat' => get_cat_ID($cat_title),
'paged' => $pageNum, //передаем текущую страницу
'post_per_page' => 1
));
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
/* посты */
<?php endwhile;
the_posts_pagination();
else :
endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question