2012-08-02 78 views
0

我在我的主頁上使用query_posts從多個帖子類型中獲取文章。我正在使用以下代碼來執行此操作。query_posts不會返回舊帖子?

<?php query_posts(array('post_type' => array('post','page','custom_post1','custom_post2','custom_post3','custom_post4','custom_post5','custom_post6'))); 
if (have_posts()) : while (have_posts()) : the_post(); // begin the Loop ?> 
/*html code goes here*/ 
<?php endwhile; endif; ?> 

它正確地提取帖子,但問題是:它不提取舊帖子。因此,例如,我有1個職位,其發佈日期爲02/july/2012,此職位將不會顯示在我的主頁上。但只要我更新日期到02/Aug/2012它開始顯示在主頁上。

因此,我可以在query_posts中添加任何代碼,以便能夠提取較舊的帖子。

回答

1

Wordpress默認獲取10個帖子或用戶從admin設置的帖子數量。

query_posts接受返回記錄數的參數。

query_posts('posts_per_page=5'); 
query_posts('posts_per_page=50'); 
+0

**哇!大聲笑我多愚蠢。非常感謝@穆罕默德亞辛** – 2012-08-03 10:25:03