diff --git a/wp-content/themes/default/archive.php b/wp-content/themes/default/archive.php
index 1d2b1de358..7152294c33 100644
--- a/wp-content/themes/default/archive.php
+++ b/wp-content/themes/default/archive.php
@@ -1,13 +1,14 @@
-
+
Archive for the ‘’ Category
-
+
+Archive for the ‘’ Tag
Archive for
@@ -40,7 +41,7 @@
- Posted in |
+ '); ?> Posted in |
diff --git a/wp-content/themes/default/search.php b/wp-content/themes/default/search.php
index 5bd1bc6fd6..ac7ec8f29a 100644
--- a/wp-content/themes/default/search.php
+++ b/wp-content/themes/default/search.php
@@ -18,7 +18,7 @@
- Posted in |
+ '); ?> Posted in |
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
index 74b3b78cac..25b66edbe0 100644
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -40,6 +40,24 @@ function get_category_link($category_id) {
return apply_filters('category_link', $catlink, $category_id);
}
+function get_tag_link( $tag_id ) {
+ global $wp_rewrite;
+ $catlink = $wp_rewrite->get_category_permastruct();
+
+ $category = &get_category($tag_id);
+ $category_nicename = $category->category_nicename;
+
+ if ( empty($catlink) ) {
+ $file = get_option('home') . '/';
+ $catlink = $file . '?tag=' . $category_nicename;
+ } else {
+
+ $catlink = str_replace('%tag%', $category_nicename, $catlink);
+ $catlink = get_option('home') . user_trailingslashit($catlink, 'category');
+ }
+ return apply_filters('tag_link', $catlink, $category_id);
+}
+
function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
$chain = '';
$parent = &get_category($id);
@@ -182,7 +200,7 @@ function get_the_tags( $before, $sep, $after ) {
$return = $before;
foreach ( $tags as $tag )
- $tag_links[] = '' . $tag->cat_name . '';
+ $tag_links[] = '' . $tag->cat_name . '';
$tag_links = join( $sep, $tag_links );
$tag_links = apply_filters( 'the_tags', $tag_links );
diff --git a/wp-includes/category.php b/wp-includes/category.php
index a8a24a5024..ba438a1840 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -206,6 +206,15 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE
return NULL;
}
+function get_category_by_slug( $slug ) {
+ global $wpdb;
+ $slug = sanitize_title( $slug );
+ if ( empty( $slug ) )
+ return false;
+ $category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " );
+ return get_category( $category );
+}
+
// Get the ID of a category from its name
function get_cat_ID($cat_name='General') {
global $wpdb;
diff --git a/wp-includes/classes.php b/wp-includes/classes.php
index 6bdfb2eff2..fa9db6048b 100644
--- a/wp-includes/classes.php
+++ b/wp-includes/classes.php
@@ -1,7 +1,7 @@
is_tag )
+ return false;
+
+ if ( empty( $slug ) )
+ return true;
+
+ $cat_obj = $wp_query->get_queried_object();
+ if ( $category == $cat_obj->category_nicename )
+ return true;
+ return false;
+}
+
function is_comments_popup () {
global $wp_query;
@@ -305,6 +319,7 @@ class WP_Query {
var $is_time = false;
var $is_author = false;
var $is_category = false;
+ var $is_tag = false;
var $is_search = false;
var $is_feed = false;
var $is_comment_feed = false;
@@ -329,6 +344,7 @@ class WP_Query {
$this->is_time = false;
$this->is_author = false;
$this->is_category = false;
+ $this->is_tag = false;
$this->is_search = false;
$this->is_feed = false;
$this->is_comment_feed = false;
@@ -383,6 +399,7 @@ class WP_Query {
, 'year'
, 'w'
, 'category_name'
+ , 'tag'
, 'author_name'
, 'feed'
, 'tb'
@@ -531,6 +548,9 @@ class WP_Query {
$this->is_category = true;
}
+ if ( '' != $qv['tag'] )
+ $this->is_tag = true;
+
if ( empty($qv['author']) || ($qv['author'] == '0') ) {
$this->is_author = false;
} else {
@@ -541,7 +561,7 @@ class WP_Query {
$this->is_author = true;
}
- if ( ($this->is_date || $this->is_author || $this->is_category) )
+ if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag ) )
$this->is_archive = true;
}
@@ -837,7 +857,7 @@ class WP_Query {
$in_cats = substr($in_cats, 0, -2);
$out_cats = substr($out_cats, 0, -2);
if ( strlen($in_cats) > 0 )
- $in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats)";
+ $in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats) AND rel_type = 'category' ";
if ( strlen($out_cats) > 0 ) {
$ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE $wpdb->post2cat.category_id IN ($out_cats)");
if ( is_array($ids) && count($ids > 0) ) {
@@ -854,6 +874,21 @@ class WP_Query {
$groupby = "{$wpdb->posts}.ID";
}
+ if ( '' != $q['tag'] ) {
+ $reqcat= get_category_by_slug( $q['tag'] );
+ if ( !empty($reqcat) )
+ $reqcat = $reqcat->cat_ID;
+ else
+ $reqcat = 0;
+
+ $q['cat'] = $reqcat;
+
+ $tables = ", $wpdb->post2cat, $wpdb->categories";
+ $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
+ $whichcat = " AND category_id IN ({$q['cat']}) AND rel_type = 'tag' ";
+ $groupby = "{$wpdb->posts}.ID";
+ }
+
// Category stuff for nice URLs
if ( '' != $q['category_name'] ) {
$reqcat = get_category_by_path($q['category_name']);
@@ -881,13 +916,15 @@ class WP_Query {
$tables = ", $wpdb->post2cat, $wpdb->categories";
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
- $whichcat = " AND category_id IN ({$q['cat']}, ";
+ $whichcat = " AND category_id IN ({$q['cat']} ";
$whichcat .= get_category_children($q['cat'], '', ', ');
$whichcat = substr($whichcat, 0, -2);
- $whichcat .= ")";
+ $whichcat .= ") AND rel_type = 'category'";
$groupby = "{$wpdb->posts}.ID";
}
+
+
// Author/user stuff
if ( empty($q['author']) || ($q['author'] == '0') ) {
diff --git a/wp-includes/template-loader.php b/wp-includes/template-loader.php
index 5b830c679a..80ba5dc339 100644
--- a/wp-includes/template-loader.php
+++ b/wp-includes/template-loader.php
@@ -35,6 +35,9 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
} else if ( is_category() && $template = get_category_template()) {
include($template);
return;
+ } else if ( is_tag() && $template = get_tag_template()) {
+ include($template);
+ return;
} else if ( is_author() && $template = get_author_template() ) {
include($template);
return;
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 2a7ac8ce0c..f359b0855d 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -328,6 +328,17 @@ function get_category_template() {
return apply_filters('category_template', $template);
}
+function get_tag_template() {
+ $template = '';
+ if ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') )
+ $template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php';
+ elseif ( file_exists(TEMPLATEPATH . "/tag.php") )
+ $template = TEMPLATEPATH . "/tag.php";
+
+ return apply_filters('tag_template', $template);
+}
+
+
function get_date_template() {
return get_query_template('date');
}