Support category names in in_category(). Fixes #4558 props robmil.
git-svn-id: https://develop.svn.wordpress.org/trunk@7030 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
54f0cd204f
commit
025073bf5c
|
@ -170,6 +170,10 @@ function get_the_category_list($separator = '', $parents='', $post_id = false) {
|
||||||
function in_category( $category ) { // Check if the current post is in the given category
|
function in_category( $category ) { // Check if the current post is in the given category
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
|
if ( !is_numeric($category) ) {
|
||||||
|
$category = get_cat_ID($category);
|
||||||
|
}
|
||||||
|
|
||||||
$categories = get_object_term_cache($post->ID, 'category');
|
$categories = get_object_term_cache($post->ID, 'category');
|
||||||
if ( false === $categories )
|
if ( false === $categories )
|
||||||
$categories = wp_get_object_terms($post->ID, 'category');
|
$categories = wp_get_object_terms($post->ID, 'category');
|
||||||
|
|
Loading…
Reference in New Issue