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:
Peter Westwood 2008-02-25 22:18:41 +00:00
parent 54f0cd204f
commit 025073bf5c
1 changed files with 4 additions and 0 deletions

View File

@ -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');