From 175dd7bca75601ee88a9ca5c103d5673ce1cdc7d Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 5 Dec 2006 06:45:48 +0000 Subject: [PATCH] Use get_the_category() within wp_get_post_categories() so that the cache is used. Props markjaquith. fixes #3430 git-svn-id: http://svn.automattic.com/wordpress/trunk@4606 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 36df770852..661c38b3b5 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -429,22 +429,12 @@ function wp_delete_post($postid = 0) { return $post; } -function wp_get_post_categories($post_ID = 0) { - global $wpdb; - - $post_ID = (int) $post_ID; - - $sql = "SELECT category_id - FROM $wpdb->post2cat - WHERE post_id = '$post_ID' - ORDER BY category_id"; - - $result = $wpdb->get_col($sql); - - if ( !$result ) - $result = array(); - - return array_unique($result); +function wp_get_post_categories($post_id = 0) { + $cats = &get_the_category($post_id); + $cat_ids = array(); + foreach ( $cats as $cat ) + $cat_ids[] = (int) $cat->cat_ID; + return array_unique($cat_ids); } function wp_get_recent_posts($num = 10) {