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;
Il valore dell'eco è 5 (il valore corretto deve essere 9). L'unico modo in cui posso farlo per restituire il valore corretto per il numero dei tuoi messaggi è quello di cambiare il calcolo $ myrecentposts2 come segue ...Perché get_posts() restituisce solo 5 post corrispondenti, quando dovrebbe restituire 9?
$myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2",'showposts' => 999));
dolci! Come lo sai? –
è nel codice wordpress http://codex.wordpress.org/Template_Tags/get_posts btw my bad - its posts_per_page anziché limit :) – roman