Answer the question
In order to leave comments, you need to log in
Pagination with multiple wp_query + offset's?
In this way, I make 7-8 posts custom, everything works fine in category.php, but pagination is nowhere, apparently due to offsets or something else... Has anyone encountered this? how to make pagination work correctly?
<?php
$categories = get_queried_object_id();
$args = array(
'posts_per_page' => 6,
'cat' => $categories
);
$ar = array(
'posts_per_page' => 2,
'offset' => 6,
'cat' => $categories
);
$arg = array(
'posts_per_page' => 6,
'offset' => 8,
'cat' => $categories
);
$query = new WP_Query( $args );
$q = new WP_Query($ar);
$qu = new WP_Query($arg);
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post(); ?>
// содержимое обычное
<?
}
}
wp_reset_postdata();
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post(); ?>
// содержимое "необычное"
<?
}
}
wp_reset_postdata();
if ( $qu->have_posts() ) {
while ( $qu->have_posts() ) {
$qu->the_post(); ?>
//содержимое обычное
<?
}
}
wp_reset_postdata();
Answer the question
In order to leave comments, you need to log in
Leave the regex as it is, and just strip off the first few characters you need :
In general, perhaps you should look towards ready-made solutions ( for example ), instead of doing such bicycle building.
Pagination works from the main query (Main WP_Query), and not from custom ones, and offsets have nothing to do with it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question