0
これは、wordpressのPHPコードであり、idのcat = 7というカテゴリの最後の15個の投稿の結果を表示しています。投稿を表示するには6-15、いずれかのガイドが必要ですwordpressの特定の数の投稿を表示する方法
<?php
$news = new WP_Query('cat=7&posts_per_page=15');
if ($news->have_posts()) :
$item_number = 0;
while ($news->have_posts()) : $news->the_post();
get_template_part('content'); ?>
<?php endwhile;
else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif;?>
注:[ページ区切りが壊れる可能性があります](https://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination)。 –
ああ、良い点。私はこれを反映するために私の答えを編集しました。 –
Matt Bureshさん、&offset = 5が問題を解決しました。 – FRQ6692