Changeset 5149 for trunk/wp-includes/query.php
- Timestamp:
- 03/31/2007 06:16:12 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.