[wp-hackers] tags and categories combined not working: is it a bug
or a feature?
Burobjorn
burobjorn at gmail.com
Wed Feb 13 16:12:58 GMT 2008
Hi,
After some trial and error and some pointers by Christine and people on
IRC it seems that using both 1 tag and 1 category produces SQL code but
no results. However using multiple tags and 1 category does give back
results. This is odd as there should be a result both times. Perhaps
this is a bug?
== what I did ==
I have a lot of posts which belong to categories. Every post belongs to
at least 2 categories, namely a parent category and a child.
i.e.
parent category: mediaskills and awarness
child category: media-awarness
Every post has also been tagged with at least one tag and mostly with
more than 2.
i.e.
elderly, kids, teens
Now I would like to get all posts in the category media-awarness (let's
say the id for this is 12) with the tags 'elderly' and 'kids'. I do this
using query url parameters:
http://mediawijsheid/?tag=ouderen+kinderen&cat=12
This results in the following query code which I dumped using
<?php global $wp_query; print_r($wp_query) ?> in the search.php template:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id =
wp_term_taxonomy.term_taxonomy_id) WHERE 1=1 AND
wp_term_taxonomy.taxonomy = 'category' AND wp_term_taxonomy.term_id IN
('12') AND wp_posts.ID IN (7, 8, 17) AND post_type IN('page', 'post')
AND (post_status = 'publish' OR post_status = 'private') GROUP BY
wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10
And I get the results I would expect. When I want to get all posts in
the category media-awarness (still using id 12) and just the tag
'elderly' I get the following SQL code and no results :
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id =
wp_term_taxonomy.term_taxonomy_id) WHERE 1=1 AND
wp_term_taxonomy.taxonomy = 'category' AND wp_term_taxonomy.term_id IN
('12') AND wp_term_taxonomy.taxonomy = 'post_tag' AND
wp_term_taxonomy.term_id IN ('19') AND post_type IN('page', 'post') AND
(post_status = 'publish' OR post_status = 'private') GROUP BY
wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10
What the heck is going on?
Any help much appreciated!
All the best,
grtz
BjornW
--
met vriendelijke groet,
Bjorn Wijers
* b u r o b j o r n .nl *
digitaal vakmanschap | digital craftsmanship
Concordiastraat 68-126
3551 EM Utrecht
The Netherlands
phone: +31 30 2444 101
http://www.burobjorn.nl
More information about the wp-hackers
mailing list