From 007689ab776a38ebe04e2a03c0a3a15700f7033b Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 7 May 2008 19:12:44 +0000 Subject: [PATCH] [7064] introduces an extra query for each call to in_category(). Avoid the query if an int is passed. git-svn-id: https://develop.svn.wordpress.org/trunk@7904 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/category-template.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 9093062e48..1217276746 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -185,9 +185,12 @@ function in_category( $category ) { // Check if the current post is in the given if ( empty($category) ) return false; - $cat_ID = get_cat_ID($category); - if ( $cat_ID ) - $category = $cat_ID; + // If category is not an int, check to see if it's a name + if ( ! is_int($category) ) { + $cat_ID = get_cat_ID($category); + if ( $cat_ID ) + $category = $cat_ID; + } $categories = get_object_term_cache($post->ID, 'category'); if ( false === $categories )