I need to check if a certain post is belongs to a category or belongs to a descendant of a certain category. IS there a wordpress function for this, or I need to do it myself ?
Edit: I should have mentioned that the WP version is 2.7. sorry
I need to check if a certain post is belongs to a category or belongs to a descendant of a certain category. IS there a wordpress function for this, or I need to do it myself ?
Edit: I should have mentioned that the WP version is 2.7. sorry
$post = get_post($id);
$category = $post->$post_category;
cat_is_ancestor_of(($parent_category, $category));
For more info see the get_post and cat is ancestor of references. Also, while somewhat difficult to find this is a good place to start for most wp development related things.
See also here: http://codex.wordpress.org/Function_Reference/in_category#Testing_if_a_post_is_in_a_descendant_category
for 2.7 or above use in_category( $category, $_post )
Regards, Vicky Biswas