Basic theme support for tags.

git-svn-id: https://develop.svn.wordpress.org/trunk@5111 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2007-03-26 08:08:31 +00:00
parent b7debfb42b
commit bfb4b8c091
4 changed files with 46 additions and 6 deletions

View File

@ -8,7 +8,7 @@ get_header();
<div class="post" id="post-<?php the_ID(); ?>">
<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
<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>
<div class="storycontent">
<?php the_content(__('(more...)')); ?>

View File

@ -14,7 +14,7 @@
<?php the_content('Read the rest of this entry &raquo;'); ?>
</div>
<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>
<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>
</div>
<?php endwhile; ?>

View File

@ -160,6 +160,42 @@ function the_category($separator = '', $parents='') {
echo get_the_category_list($separator, $parents);
}
function get_post_tags( $post_id = 0 ) {
global $tag_cache, $blog_id;
$post_id = (int) $post_id;
if ( !isset( $tag_cache[$blog_id][$post_id] ) )
update_post_category_cache( $post_id ); // loads $tag_cache
return $tag_cache[$blog_id][$post_id];
}
function get_the_tags( $before, $sep, $after ) {
global $post;
if ( !$post )
return false; // in-the-loop function
$tags = get_post_tags( $post->ID );
if ( empty( $tags ) )
return false;
$return = $before;
foreach ( $tags as $tag )
$tag_links[] = '<a href="' . get_category_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>';
$tag_links = join( $sep, $tag_links );
$tag_links = apply_filters( 'the_tags', $tag_links );
$return .= $tag_links;
$return .= $after;
return $return;
}
function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
echo get_the_tags( $before, $sep, $after );
}
function category_description($category = 0) {
global $cat;
if ( !$category )

View File

@ -635,7 +635,7 @@ function clean_page_cache($id) {
}
function update_post_category_cache($post_ids) {
global $wpdb, $category_cache, $blog_id;
global $wpdb, $category_cache, $tag_cache, $blog_id;
if ( empty($post_ids) )
return;
@ -656,13 +656,17 @@ function update_post_category_cache($post_ids) {
return;
$post_id_list = join( ',', $post_id_array ); // with already cached stuff removed
$dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
$dogs = $wpdb->get_results("SELECT post_id, category_id, rel_type FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
if ( empty($dogs) )
return;
foreach ($dogs as $catt)
$category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
foreach ($dogs as $catt) {
if ( 'category' == $catt->rel_type )
$category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
elseif ( 'tag' == $catt->rel_type )
$tag_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
}
}
function update_post_caches(&$posts) {