Make WordPress Core


Ignore:
Timestamp:
03/01/2005 09:10:12 AM (22 years ago)
Author:
matt
Message:

Category query speedup and indentation fixes. Hat tip: Scott. ​http://mosquito.wordpress.org/view.php?id=1005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template-functions-category.php

    r2387 r2396  
    44    global $post, $wpdb, $category_cache;
    55
    6     if (! $id) {
    7         $id = $post->ID;
    8     }
    9 
    10     if ($category_cache[$id]) {
    11                          $categories = $category_cache[$id];
     6        if ( !$id )
     7                $id = $post->ID;
     8
     9        if ( $category_cache[$id] ) {
     10                $categories = $category_cache[$id];
    1211    } else {
    13         $categories = $wpdb->get_results("
    14             SELECT category_id, cat_name, category_nicename, category_description, category_parent
    15             FROM  $wpdb->categories, $wpdb->post2cat
    16             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$id'
    17             ");
    18    
    19     }
    20 
    21                 if (!empty($categories))
    22                         sort($categories);
    23                 else
    24                         $categories = array();
    25 
    26                 return $categories;
     12                $categories = $wpdb->get_results("
     13                SELECT category_id, cat_name, category_nicename, category_description, category_parent
     14                FROM  $wpdb->categories, $wpdb->post2cat
     15                WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$id'
     16                ");
     17    }
     18
     19        if (!empty($categories))
     20                sort($categories);
     21        else
     22                $categories = array();
     23
     24        return $categories;
    2725}
    2826
Note: See TracChangeset for help on using the changeset viewer.