我每页设置了 9 个帖子 php 查询,但它不起作用。我正在使用自定义主题。当我改变主题时,它工作正常。如何解决每页5项的博客文章?
在此处输入图像描述
显示带有分页的博客文章列表的代码:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'post_type' => 'post', // You can add a custom post type if you like
'paged' => $paged,
'posts_per_page' => 10
));
if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php // post content goes here ?>
<?php endwhile; ?>
<?php my_pagination(); ?>
<?php else : ?>
<?php // no posts found message goes here ?>
<?php endif; ?>
希望这对你有用。