我無法用showposts替換posts_per_page以限制列表中返回的帖子數量。當我使用showposts時,根據我在showposts限制器中指定的帖子數量正確顯示生成的菜單列表。但是,當我使用posts_per_page時,後限制號碼似乎無關緊要。結果列表顯示所有帖子,超過限制器數量。showposts VS posts_per_page。 showposts作品完美但不推薦!
例子:
這完美的作品:
$myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$catHidden",'showposts' => $cb2_recent_count));
foreach($myrecentposts as $idxrecent=>$post) {
然而,當我在posts_per_page子,這不工作...
$myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$catHidden",'posts_per_page' => $cb2_recent_count));
foreach($myrecentposts as $idxrecent=>$post) {
*我只是想獲取posts_per_page工作,因爲我明白showposts已被棄用。
所以我應該用numberposts替換showposts?並且numberposts是不是在我認爲瀕臨滅絕的名單:) – 2010-07-26 13:43:50
謝謝DM,工作就像一個魅力! – 2010-07-26 13:54:49
我認爲你的原始答案是有用的,編輯似乎有點模糊了這個問題。據我所知,沒有什麼能夠阻止你使用'get_posts'分頁,除了語義混淆。 – 2010-07-26 14:42:39