global $post;
$cat1=get_cat_ID('test1');
$cat2=get_cat_ID('test2');
$myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2",'showposts' => 5));
$myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2"));
$myrecentpostscount = count($myrecentposts2);
echo $myrecentpostscount;
回聲的值是5(正確的值應該是9)。我可以得到它的發帖量返回正確的值的唯一方法是改變$ myrecentposts2計算如下...爲什麼get_posts()只返回5個匹配的帖子,當它返回9?
$myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2",'showposts' => 999));
甜蜜的樣子!你怎麼知道的? – 2010-01-25 20:39:46
它在wordpress codex http://codex.wordpress.org/Template_Tags/get_posts btw我的壞 - 它的posts_per_page而不是限制:) – roman 2010-01-26 07:43:04