tags:

views:

89

answers:

2
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;

The value of the echo is 5 (the correct value should be 9). The only way I can get it to return the correct value for the post count is to change the $myrecentposts2 calculation as follows...

$myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2",'showposts' => 999));
A: 

the default posts_per_page value is 5

to remove the limit use posts_per_page=-1

roman
Sweet! How'd you know that?
Scott B
its in the wordpress codex http://codex.wordpress.org/Template_Tags/get_postsbtw my bad - its posts_per_page instead of limit :)
roman
A: 

Also, showposts is deprecated as of WP 2.9 (or maybe even 2.8), use posts_per_page whenever you're trying to control the amount of posts returned.

Gipetto
I did not know that. Thanks Gipetto!What version was posts_per_page introduced? In other words, I don't want to change from showposts if its likely to throw errors on recent wordpress releases...
Scott B
Gipetto, when I change from 'showposts' => -1 to 'posts_per_page' => -1, rather than showing all posts, I only get 5. I'm switching back to showposts for now.
Scott B