Ticket #7544 (closed defect (bug): invalid)

Opened 5 months ago

Last modified 5 months ago

Multiple Category Handling Wrong

Reported by: zackdesign Assigned to: anonymous
Priority: normal Milestone: 2.6.2
Component: General Version: 2.6.1
Severity: trivial Keywords: category, query_posts, categories, multiple, select
Cc:

Description

To create this problem I was doing the following:

1. I created a plugin 2. This plugin has an action call to 'init' 3. The init function runs and then based upon a POST variable runs the following code:

query_posts(array('categoryin' => array($sql)));

4. I've checked and tested $sql variable to ensure that it's passing the correct values. 5. Testing further, it would appear that the implementation of categoryin is extremely haphazard. Sometimes it works, sometimes it doesn't. I'd like to request that this get fixed soon so that I don't have to resort to doing a custom query...!

What I want is for the user to select a set of categories and only show posts that span every single one of those categories. At the moment it shows the correct output sometimes and then other times shows the post even if there is one category it hasn't been added to. I have a setup of parent and child categories, with child categories used for the testing across parents.

e.g.

parent 1

sub 1 sub 2

parent 2

sub2 1 sub2 2

I test across more than two parents and using categories like so: sub 1, sub2 2. I never choose multiple child categories under the one parent.

Hopefully this describes my problem in enough detail! You can see it an action currently at http://skopelostopos.net/ (see the drop-downs under Properties).

By the time you see it I may or may not have 1) fixed it using custom queries or 2) upgraded wordpress to the fix that I hope this ticket will engender...

Change History

08/19/08 05:28:02 changed by zackdesign

My apologies for the formatting:

query_posts(array('category__in' => array($sql))); 

(follow-up: ↓ 3 ) 08/19/08 16:30:11 changed by ryan

What's in $sql? category__in accepts an array of category IDs. If you want to do intersections, use category__and.

(in reply to: ↑ 2 ) 08/20/08 02:35:23 changed by zackdesign

  • status changed from new to closed.
  • resolution set to invalid.
  • severity changed from major to trivial.

Replying to ryan:

What's in $sql? category__in accepts an array of category IDs. If you want to do intersections, use category__and.

$sql was a constantly changing text string modeled after: http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters

It would appear that this documentation is misleading. I just tried using a normal array and it worked perfectly!