Make WordPress Core

Changeset 5111


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

Basic theme support for tags.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/classic/index.php

    r4495 r5111  
    99<div class="post" id="post-<?php the_ID(); ?>">
    1010     <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    11     <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
     11    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_tags('Tags: ', ', ', ' &#8212; '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
    1212
    1313    <div class="storycontent">
  • trunk/wp-content/themes/default/index.php

    r3517 r5111  
    1515                </div>
    1616
    17                 <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
     17                <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
    1818            </div>
    1919
  • 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;
  • trunk/wp-includes/functions.php

    r5109 r5111  
    636636
    637637function update_post_category_cache($post_ids) {
    638     global $wpdb, $category_cache, $blog_id;
     638    global $wpdb, $category_cache, $tag_cache, $blog_id;
    639639
    640640    if ( empty($post_ids) )
     
    657657    $post_id_list = join( ',', $post_id_array ); // with already cached stuff removed
    658658
    659     $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
     659    $dogs = $wpdb->get_results("SELECT post_id, category_id, rel_type FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
    660660
    661661    if ( empty($dogs) )
    662662        return;
    663663
    664     foreach ($dogs as $catt)
    665         $category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
     664    foreach ($dogs as $catt) {
     665        if ( 'category' == $catt->rel_type )
     666            $category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
     667        elseif ( 'tag' == $catt->rel_type )
     668            $tag_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
     669    }
    666670}
    667671
Note: See TracChangeset for help on using the changeset viewer.