Fix in_category() when checking non-cached categories. fixes #7181
git-svn-id: http://svn.automattic.com/wordpress/trunk@9289 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
85bc4ebd08
commit
461ac5808d
|
@ -288,14 +288,21 @@ function in_category( $category ) {
|
|||
}
|
||||
|
||||
$categories = get_object_term_cache( $post->ID, 'category' );
|
||||
if ( false === $categories )
|
||||
$categories = wp_get_object_terms( $post->ID, 'category' );
|
||||
if ( false !== $categories ) {
|
||||
if ( array_key_exists( $category, $categories ) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
$categories = wp_get_object_terms( $post->ID, 'category', 'fields=ids' );
|
||||
if ( is_array($categories) && in_array($category, $categories) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the category list for the post.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue