Changeset 5149
- Timestamp:
- 03/31/2007 06:16:12 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/default/archive.php
r5105 r5149 2 2 3 3 <div id="content" class="narrowcolumn"> 4 4 <?php is_tag(); ?> 5 5 <?php if (have_posts()) : ?> 6 6 … … 8 8 <?php /* If this is a category archive */ if (is_category()) { ?> 9 9 <h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2> 10 10 <?php } elseif( is_tag() ) { ?> 11 <h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Tag</h2> 11 12 <?php /* If this is a daily archive */ } elseif (is_day()) { ?> 12 13 <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2> … … 41 42 </div> 42 43 43 <p class="postmetadata"> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>44 <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 44 45 45 46 </div> -
trunk/wp-content/themes/default/search.php
r3517 r5149 19 19 <small><?php the_time('l, F jS, Y') ?></small> 20 20 21 <p class="postmetadata"> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>21 <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 22 22 </div> 23 23 -
trunk/wp-includes/category-template.php
r5111 r5149 39 39 } 40 40 return apply_filters('category_link', $catlink, $category_id); 41 } 42 43 function get_tag_link( $tag_id ) { 44 global $wp_rewrite; 45 $catlink = $wp_rewrite->get_category_permastruct(); 46 47 $category = &get_category($tag_id); 48 $category_nicename = $category->category_nicename; 49 50 if ( empty($catlink) ) { 51 $file = get_option('home') . '/'; 52 $catlink = $file . '?tag=' . $category_nicename; 53 } else { 54 55 $catlink = str_replace('%tag%', $category_nicename, $catlink); 56 $catlink = get_option('home') . user_trailingslashit($catlink, 'category'); 57 } 58 return apply_filters('tag_link', $catlink, $category_id); 41 59 } 42 60 … … 183 201 $return = $before; 184 202 foreach ( $tags as $tag ) 185 $tag_links[] = '<a href="' . get_ category_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>';203 $tag_links[] = '<a href="' . get_tag_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>'; 186 204 187 205 $tag_links = join( $sep, $tag_links ); -
trunk/wp-includes/category.php
r5119 r5149 207 207 } 208 208 209 function get_category_by_slug( $slug ) { 210 global $wpdb; 211 $slug = sanitize_title( $slug ); 212 if ( empty( $slug ) ) 213 return false; 214 $category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " ); 215 return get_category( $category ); 216 } 217 209 218 // Get the ID of a category from its name 210 219 function get_cat_ID($cat_name='General') { -
trunk/wp-includes/classes.php
r5051 r5149 2 2 3 3 class WP { 4 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', ' feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');4 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots'); 5 5 6 6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type'); -
trunk/wp-includes/query.php
r5087 r5149 84 84 return true; 85 85 86 return false; 87 } 88 89 function is_tag( $slug = '' ) { 90 global $wp_query; 91 if ( !$wp_query->is_tag ) 92 return false; 93 94 if ( empty( $slug ) ) 95 return true; 96 97 $cat_obj = $wp_query->get_queried_object(); 98 if ( $category == $cat_obj->category_nicename ) 99 return true; 86 100 return false; 87 101 } … … 306 320 var $is_author = false; 307 321 var $is_category = false; 322 var $is_tag = false; 308 323 var $is_search = false; 309 324 var $is_feed = false; … … 330 345 $this->is_author = false; 331 346 $this->is_category = false; 347 $this->is_tag = false; 332 348 $this->is_search = false; 333 349 $this->is_feed = false; … … 384 400 , 'w' 385 401 , 'category_name' 402 , 'tag' 386 403 , 'author_name' 387 404 , 'feed' … … 532 549 } 533 550 551 if ( '' != $qv['tag'] ) 552 $this->is_tag = true; 553 534 554 if ( empty($qv['author']) || ($qv['author'] == '0') ) { 535 555 $this->is_author = false; … … 542 562 } 543 563 544 if ( ($this->is_date || $this->is_author || $this->is_category ) )564 if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag ) ) 545 565 $this->is_archive = true; 546 566 } … … 838 858 $out_cats = substr($out_cats, 0, -2); 839 859 if ( strlen($in_cats) > 0 ) 840 $in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats) ";860 $in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats) AND rel_type = 'category' "; 841 861 if ( strlen($out_cats) > 0 ) { 842 862 $ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE $wpdb->post2cat.category_id IN ($out_cats)"); … … 855 875 } 856 876 877 if ( '' != $q['tag'] ) { 878 $reqcat= get_category_by_slug( $q['tag'] ); 879 if ( !empty($reqcat) ) 880 $reqcat = $reqcat->cat_ID; 881 else 882 $reqcat = 0; 883 884 $q['cat'] = $reqcat; 885 886 $tables = ", $wpdb->post2cat, $wpdb->categories"; 887 $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) "; 888 $whichcat = " AND category_id IN ({$q['cat']}) AND rel_type = 'tag' "; 889 $groupby = "{$wpdb->posts}.ID"; 890 } 891 857 892 // Category stuff for nice URLs 858 893 if ( '' != $q['category_name'] ) { … … 882 917 $tables = ", $wpdb->post2cat, $wpdb->categories"; 883 918 $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) "; 884 $whichcat = " AND category_id IN ({$q['cat']} ,";919 $whichcat = " AND category_id IN ({$q['cat']} "; 885 920 $whichcat .= get_category_children($q['cat'], '', ', '); 886 921 $whichcat = substr($whichcat, 0, -2); 887 $whichcat .= ") ";922 $whichcat .= ") AND rel_type = 'category'"; 888 923 $groupby = "{$wpdb->posts}.ID"; 889 924 } 925 926 890 927 891 928 // Author/user stuff -
trunk/wp-includes/template-loader.php
r5104 r5149 34 34 return; 35 35 } else if ( is_category() && $template = get_category_template()) { 36 include($template); 37 return; 38 } else if ( is_tag() && $template = get_tag_template()) { 36 39 include($template); 37 40 return; -
trunk/wp-includes/theme.php
r5087 r5149 329 329 } 330 330 331 function get_tag_template() { 332 $template = ''; 333 if ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') ) 334 $template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php'; 335 elseif ( file_exists(TEMPLATEPATH . "/tag.php") ) 336 $template = TEMPLATEPATH . "/tag.php"; 337 338 return apply_filters('tag_template', $template); 339 } 340 341 331 342 function get_date_template() { 332 343 return get_query_template('date');
Note: See TracChangeset
for help on using the changeset viewer.