3つのクエリがcategory.phpにあり、すべてのループに対してページネーションが必要ですが、残念ながら最初のループは動作しています。オフセットを取り除くとうまくいくが、私はひどくポストをオフセットする必要があるので、オフセットのために問題が発生していることがわかった。クエリを修正するにはどうすればよいですか?以下は私のコードです。カテゴリ3のpaginationが動作していません。クエリ
<div class="row" id="CatContent">
<div class="col-md-8 col-sm-12">
<div class="leadnewsboxtitle">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$category = get_category(get_query_var('cat'));
$cat_id = $category->cat_ID;
$postquery = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 1,
'cat' => $cat_id,
'paged' => $paged
));
while($postquery->have_posts()) : $postquery->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h2>
<p><?php read_more(25); ?> ...</p>
<?php endwhile; ?>
</div>
</div>
<div class="col-md-4 col-sm-12 col-xs-12 twoboxlist">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$category = get_category(get_query_var('cat'));
$cat_id = $category->cat_ID;
$postquery = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 2,
'cat' => $cat_id,
'offset' => 1,
'paged' => $paged
));
while($postquery->have_posts()) : $postquery->the_post(); ?>
<div class="col-md-12 col-sm-6 col-xs-6">
<div class="category-news-title">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h2>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="category-news-output">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$category = get_category(get_query_var('cat'));
$cat_id = $category->cat_ID;
$postquery = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 9,
'cat' => $cat_id,
'offset' => 3,
'paged' => $paged
));
while($postquery->have_posts()) : $postquery->the_post(); ?>
<div class="col-md-4 col-sm-6 col-xs-6">
<div class="category-news-title">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></h2>
</div>
</div>
<?php endwhile; ?>
</div>
<?php the_posts_pagination(
array(
'prev_text' => __('Prev', 'btimes'),
'next_text' => __('Next', 'btimes'),
'screen_reader_text' => ' '
)); ?>
事前に感謝任意の助けが理解されるであろう。
あなたのコメントをありがとうが、まだ問題に直面しています。私はオフセットのためだと思う。他の解決策を教えてください。 – Mukut