Update in_category() to use object term cache API. Props technosailor. fixes #4442

git-svn-id: https://develop.svn.wordpress.org/trunk@5868 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-08-14 03:01:26 +00:00
parent 3e5d2230d2
commit 44afc295c3
1 changed files with 5 additions and 2 deletions

View File

@ -156,9 +156,12 @@ function get_the_category_list($separator = '', $parents='') {
}
function in_category( $category ) { // Check if the current post is in the given category
global $object_term_cache, $post, $blog_id;
global $post, $blog_id;
if ( isset( $object_term_cache[$blog_id][$post->ID]['category'][$category] ) )
$categories = get_object_term_cache($post->ID, 'category');
if ( false === $categories )
$categories = get_object_terms($post->ID, 'category');
if(array_key_exists($category, $categories))
return true;
else
return false;