簡體   English   中英

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

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

我目前正在使用它,但是當我單擊“下一頁”時,它在所有頁面上顯示相同的三個帖子,而不是顯示接下來的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>

拾取分頁的變量並在查詢中使用它。

$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