ページにページネーションを追加しようとしていますが、表示される投稿の数を制限することすらできません。これは奇妙な問題です。設定 - >私は1ページあたりの投稿数が2に設定されているので、何の効果もありません。私のクエリとループは次のとおりです。WPページネーションが動作しない
<?php
$args = array(
'post_type' => array('webinar'),
'post_status' => array('publish'),
'posts_per_page' => '2',
'order' => 'DESC',
'orderby' => 'date',
'tax_query' => array(
array(
'taxonomy' => 'webinar-status',
'field' => 'id',
'terms' => 178
)
)
);
// The Query
$archived_webinar_query = new WP_Query($args); $counter = 1;
// The Loop
if ($archived_webinar_query->have_posts()) {
while ($archived_webinar_query->have_posts()) {
$archived_webinar_query->the_post(); ?>
<div class="classes<?php if ($counter % 2 == 0){ echo('f-right l-nmr'); } ?>">
<a href="<?php the_permalink(); ?>" target="_self" class="c-ltBlue"><?php the_title(); ?>
//other stuff here
</div>
<?php $counter++ ;}
// Restore original Post Data
wp_reset_postdata();
} else { ?>
<p class="l-twelve l-mb1 f-reg c-gray f-size16 f-l-height24">No archived webinars are available at this time.</p>
<?php }
?>
てみ ' 'posts_per_page' => 2'、それは整数型です。 – Junaid
posts_per_pageを2に設定して「効果がない」と言うと、それはまだすべての投稿を返すのですか、まったく返さないのですか? – FluffyKitten
@Junaidありがとうございます。それはそれをした、私の部分で愚かな間違い! –