[wp-trac] [WordPress Trac] #10014: Select multiple categories
doesn't work
WordPress Trac
wp-trac at lists.automattic.com
Tue Jun 2 21:17:40 GMT 2009
#10014: Select multiple categories doesn't work
--------------------------+-------------------------------------------------
Reporter: csseur3 | Owner: filosofo
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.8
Component: Taxonomy | Version: 2.7.1
Severity: normal | Keywords: categories
--------------------------+-------------------------------------------------
i read this before:
http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query#Query_based_on_Custom_Field_and_Category
and i try to make:
{{{
<?php
$test_count = $wpdb->get_var("SELECT SUM(meta_value+0) FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
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)
WHERE $wpdb->term_taxonomy.term_id = 97,60,61,134,89
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->postmeta.meta_key = 'adherents'
ORDER BY $wpdb->postmeta.meta_value ASC");
echo '' . $test_count . '';
?>
}}}
or
{{{
<?php
$test_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
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)
WHERE $wpdb->term_taxonomy.term_id = 97,60,61,134,89
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->postmeta.meta_key = 'adherents'
ORDER BY $wpdb->postmeta.meta_value ASC");
echo '' . $test_count . '';
?>
}}}
to count number of "adherents" or number of the posts.
There is no working: it is impossible to select multiple categories.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10014>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list