Changeset 5530 for trunk/wp-includes/query.php
- Timestamp:
- 05/23/2007 06:59:12 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r5521 r5530 77 77 $cat_obj = $wp_query->get_queried_object(); 78 78 79 if ( $category == $cat_obj-> cat_ID)80 return true; 81 else if ( $category == $cat_obj-> cat_name )82 return true; 83 elseif ( $category == $cat_obj-> category_nicename)79 if ( $category == $cat_obj->term_id ) 80 return true; 81 else if ( $category == $cat_obj->name ) 82 return true; 83 elseif ( $category == $cat_obj->slug ) 84 84 return true; 85 85 … … 843 843 $q['cat'] = ''.urldecode($q['cat']).''; 844 844 $q['cat'] = addslashes_gpc($q['cat']); 845 $join = " LEFT JOIN $wpdb-> post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";845 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) "; 846 846 $cat_array = preg_split('/[,\s]+/', $q['cat']); 847 847 $in_cats = $out_cats = $out_posts = ''; … … 858 858 $out_cats = substr($out_cats, 0, -2); 859 859 if ( strlen($in_cats) > 0 ) 860 $in_cats = " AND $wpdb-> post2cat.category_id IN ($in_cats) AND rel_type = 'category'";860 $in_cats = " AND $wpdb->term_taxonomy.term_id IN ({$q['cat']}) "; 861 861 if ( strlen($out_cats) > 0 ) { 862 // TODO 862 863 $ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE $wpdb->post2cat.category_id IN ($out_cats)"); 863 864 if ( is_array($ids) && count($ids > 0) ) { … … 871 872 $out_cats = ''; 872 873 } 873 $whichcat = $in_cats . $out_cats; 874 $whichcat = " AND $wpdb->term_taxonomy.taxonomy = 'category' "; 875 $whichcat .= $in_cats . $out_cats; 874 876 $groupby = "{$wpdb->posts}.ID"; 875 877 } … … 883 885 884 886 $q['tag_id'] = $reqtag; 885 // TODO: use term taxonomy886 $tables = ", $wpdb->post2cat, $wpdb->categories";887 887 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) "; 888 888 $whichcat = " AND $wpdb->term_taxonomy.term_id IN ({$q['tag_id']}) AND $wpdb->term_taxonomy.taxonomy = 'post_tag' "; … … 909 909 910 910 if ( !empty($reqcat) ) 911 $reqcat = $reqcat-> cat_ID;911 $reqcat = $reqcat->term_id; 912 912 else 913 913 $reqcat = 0; … … 915 915 $q['cat'] = $reqcat; 916 916 917 $ tables = ", $wpdb->post2cat, $wpdb->categories";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)";919 $whichcat = " AND category_id IN ({$q['cat']}, ";917 $join = " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) "; 918 $whichcat = " AND $wpdb->term_taxonomy.taxonomy = 'category' "; 919 $whichcat .= "AND $wpdb->term_taxonomy.term_id IN ({$q['cat']}, "; 920 920 $whichcat .= get_category_children($q['cat'], '', ', '); 921 921 $whichcat = substr($whichcat, 0, -2); 922 $whichcat .= ") AND rel_type = 'category'";922 $whichcat .= ")"; 923 923 $groupby = "{$wpdb->posts}.ID"; 924 924 }
Note: See TracChangeset
for help on using the changeset viewer.