Make WordPress Core


Ignore:
Timestamp:
04/09/2009 04:00:40 PM (17 years ago)
Author:
azaozz
Message:

Tag descriptions, props aaroncampbell, fixes #9381

File:
1 edited

Legend:

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

    r10888 r10903  
    294294 */
    295295function category_description( $category = 0 ) {
    296     global $cat;
    297     if ( !$category )
    298         $category = $cat;
    299 
    300     return get_term_field( 'description', $category, 'category' );
     296    return term_description( $category, 'category' );
    301297}
    302298
     
    800796
    801797/**
     798 * Retrieve tag description.
     799 *
     800 * @since 2.8
     801 *
     802 * @param int $tag Optional. Tag ID. Will use global tag ID by default.
     803 * @return string Tag description, available.
     804 */
     805function tag_description( $tag = 0 ) {
     806    return term_description( $tag );
     807}
     808
     809/**
     810 * Retrieve term description.
     811 *
     812 * @since 2.8
     813 *
     814 * @param int $term Optional. Term ID. Will use global term ID by default.
     815 * @return string Term description, available.
     816 */
     817function term_description( $term = 0, $taxonomy = 'post_tag' ) {
     818    if ( !$term && ( is_tax() || is_tag() || is_category() ) ) {
     819        global $wp_query;
     820        $term = $wp_query->get_queried_object();
     821        $taxonomy = $term->taxonomy;
     822        $term = $term->term_id;
     823    }
     824    return get_term_field( 'description', $term, $taxonomy );
     825}
     826
     827/**
    802828 * Retrieve the terms of the taxonomy that are attached to the post.
    803829 *
Note: See TracChangeset for help on using the changeset viewer.