dimanche 28 décembre 2014

Check if an array of posts has posts from a specific category


I have an $array that prints out to be as follows.


Array ( [post-12] => 12 [post-160] => 160 )


What WordPress function could I use to check how many of the post ID's in the array belong to a specific category, say category with ID 45.


I tried doing the following.



$post_id_array = $array;
$category = '45';
$count = count(in_category( $category, $post_id_array ));
echo $count;


It doesn't work.





Aucun commentaire:

Enregistrer un commentaire