From ece120b57f4f00c581cfa2659fedd9fb10081877 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 21 Aug 2007 18:39:45 +0000 Subject: [PATCH] Some tag api additions from andy. git-svn-id: https://develop.svn.wordpress.org/trunk@5912 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/category.php | 2 +- wp-includes/general-template.php | 15 +++++++++++++++ wp-includes/query.php | 7 ++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/wp-includes/category.php b/wp-includes/category.php index 2f36b526f8..030572b57f 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -128,7 +128,7 @@ function &get_tags($args = '') { return apply_filters('get_tags', $cache[$key], $args); - $tags = get_terms('post_tag'); + $tags = get_terms('post_tag', $args); if ( empty($tags) ) return array(); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 9699e64e4a..cb3df3b01e 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -277,6 +277,21 @@ function single_cat_title($prefix = '', $display = true ) { } +function single_tag_title($prefix = '', $display = true ) { + $tag_id = intval( get_query_var('tag_id') ); + if ( !empty($tag_id) ) { + $my_tag = &get_term($tag_id, 'post_tag'); + $my_tag_name = apply_filters('single_tag_title', $my_tag->name); + if ( !empty($my_tag_name) ) { + if ( $display ) + echo $prefix.strip_tags($my_tag_name); + else + return strip_tags($my_tag_name); + } + } +} + + function single_month_title($prefix = '', $display = true ) { global $wp_locale; diff --git a/wp-includes/query.php b/wp-includes/query.php index cea523f5f0..f91412769a 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1294,6 +1294,11 @@ class WP_Query { $category = &get_category($cat); $this->queried_object = &$category; $this->queried_object_id = (int) $cat; + } else if ($this->is_tag) { + $tag_id = $this->get('tag_id'); + $tag = &get_term($tag_id, 'post_tag'); + $this->queried_object = &$tag; + $this->queried_object_id = (int) $tag_id; } else if ($this->is_posts_page) { $this->queried_object = & get_page(get_option('page_for_posts')); $this->queried_object_id = (int) $this->queried_object->ID; @@ -1402,4 +1407,4 @@ function setup_postdata($post) { return true; } -?> \ No newline at end of file +?>