From 6da1524825d5d898cc05098672434360e356d430 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 24 Dec 2007 21:21:16 +0000 Subject: [PATCH] Fetch only post category terms in get_posts(). Props MichaelH. fixes #5317 git-svn-id: https://develop.svn.wordpress.org/trunk@6490 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 91ba23f688..28349ec178 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -365,7 +365,7 @@ function get_posts($args) { $query .= empty( $post_type ) ? '' : $wpdb->prepare("AND post_type = %s ", $post_type); $query .= empty( $post_status ) ? '' : $wpdb->prepare("AND post_status = %s ", $post_status); $query .= "$exclusions $inclusions " ; - $query .= empty( $category ) ? '' : $wpdb->prepare("AND ($wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = %d) ", $category); + $query .= empty( $category ) ? '' : $wpdb->prepare("AND ($wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy = 'category')"); $query .= empty( $post_parent ) ? '' : $wpdb->prepare("AND $wpdb->posts.post_parent = %d ", $post_parent); // expected_slashed ($meta_key, $meta_value) -- Also, this looks really funky, doesn't seem like it works $query .= empty( $meta_key ) | empty($meta_value) ? '' : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )";