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
This commit is contained in:
parent
7d4c7408f5
commit
175dd7bca7
|
@ -429,22 +429,12 @@ function wp_delete_post($postid = 0) {
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_get_post_categories($post_ID = 0) {
|
function wp_get_post_categories($post_id = 0) {
|
||||||
global $wpdb;
|
$cats = &get_the_category($post_id);
|
||||||
|
$cat_ids = array();
|
||||||
$post_ID = (int) $post_ID;
|
foreach ( $cats as $cat )
|
||||||
|
$cat_ids[] = (int) $cat->cat_ID;
|
||||||
$sql = "SELECT category_id
|
return array_unique($cat_ids);
|
||||||
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_recent_posts($num = 10) {
|
function wp_get_recent_posts($num = 10) {
|
||||||
|
|
Loading…
Reference in New Issue