简体   繁体   English

如何使用php限制wordpress博客中的帖子数量?

[英]How to put a limit on the number of posts in a wordpress blog using php?

I'm currently using this but when I click on "next page" it shows the same three posts on all the pages instead of showing the next 3 posts and so fourth. 我目前正在使用它,但是当我单击“下一页”时,它在所有页面上显示相同的三个帖子,而不是显示接下来的3个帖子,因此是第四个。

<?php 
    global $query_string;
    query_posts ('posts_per_page=3');
    if (have_posts()) : while (have_posts()) : the_post();
?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p>?php the_time(); ?></p>
<?php the_content(); ?>
<p><?php the_tags(); ?></p>
<p><?php next_posts_link(); ?></p>
<p><?php previous_posts_link(); ?></p>
<h1>Not Found</h1>
<p>Silly monkey.</p>

Pick up the paged variable and use it in your query. 拾取分页的变量并在查询中使用它。

$paged = get_query_var( 'paged', 1 );
query_posts ('posts_per_page=3&paged=' . $paged);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM