Make WordPress Core


Ignore:
Timestamp:
03/26/2007 08:08:31 AM (20 years ago)
Author:
matt
Message:

Basic theme support for tags.

File:
1 edited

Legend:

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

    r5090 r5111  
    161161}
    162162
     163function get_post_tags( $post_id = 0 ) {
     164        global $tag_cache, $blog_id;
     165
     166        $post_id = (int) $post_id;
     167       
     168        if ( !isset( $tag_cache[$blog_id][$post_id] ) )
     169                update_post_category_cache( $post_id ); // loads $tag_cache
     170
     171        return $tag_cache[$blog_id][$post_id];
     172}
     173
     174function get_the_tags( $before, $sep, $after ) {
     175        global $post;
     176        if ( !$post )
     177                return false; // in-the-loop function
     178
     179        $tags = get_post_tags( $post->ID );
     180        if ( empty( $tags ) )
     181                return false;
     182       
     183        $return = $before;
     184        foreach ( $tags as $tag )
     185                $tag_links[] = '<a href="' . get_category_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>';
     186
     187        $tag_links = join( $sep, $tag_links );
     188        $tag_links = apply_filters( 'the_tags', $tag_links );
     189        $return .= $tag_links;
     190
     191        $return .= $after;
     192        return $return;
     193}
     194
     195function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
     196        echo get_the_tags( $before, $sep, $after );
     197}
     198
    163199function category_description($category = 0) {
    164200        global $cat;
Note: See TracChangeset for help on using the changeset viewer.