Make WordPress Core

Changeset 4606


Ignore:
Timestamp:
12/05/2006 06:45:48 AM (18 years ago)
Author:
ryan
Message:

Use get_the_category() within wp_get_post_categories() so that the cache is used. Props markjaquith. fixes #3430

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r4601 r4606  
    430430}
    431431
    432 function wp_get_post_categories($post_ID = 0) {
    433     global $wpdb;
    434 
    435     $post_ID = (int) $post_ID;
    436 
    437     $sql = "SELECT category_id
    438         FROM $wpdb->post2cat
    439         WHERE post_id = '$post_ID'
    440         ORDER BY category_id";
    441 
    442     $result = $wpdb->get_col($sql);
    443 
    444     if ( !$result )
    445         $result = array();
    446 
    447     return array_unique($result);
     432function wp_get_post_categories($post_id = 0) {
     433    $cats = &get_the_category($post_id);
     434    $cat_ids = array();
     435    foreach ( $cats as $cat )
     436        $cat_ids[] = (int) $cat->cat_ID;
     437    return array_unique($cat_ids);
    448438}
    449439
Note: See TracChangeset for help on using the changeset viewer.