Make WordPress Core


Ignore:
Timestamp:
06/04/2004 02:36:46 AM (22 years ago)
Author:
rboren
Message:

Add %category% support to get_permalink.

File:
1 edited

Legend:

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

    r1375 r1385  
    11<?php
    22
    3 function get_the_category() {
     3function get_the_category($id = false) {
    44    global $post, $wpdb, $category_cache;
    5     if ($category_cache[$post->ID]) {
    6         return $category_cache[$post->ID];
     5
     6    if (! $id) {
     7        $id = $post->ID;
     8    }
     9
     10    if ($category_cache[$id]) {
     11        return $category_cache[$id];
    712    } else {
    813        $categories = $wpdb->get_results("
    914            SELECT category_id, cat_name, category_nicename, category_description, category_parent
    1015            FROM  $wpdb->categories, $wpdb->post2cat
    11             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $post->ID
     16            WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $id
    1217            ");
    1318   
Note: See TracChangeset for help on using the changeset viewer.