I would like to show all entries that have two categories selected = apples and oranges rather than apples or oranges. Is this possible to do - anyone know any snappy php code to accomplish with a query or some such goodyness?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
October 29, 2007 7:16pm
Subscribe [2]#1 / Oct 29, 2007 7:16pm
I would like to show all entries that have two categories selected = apples and oranges rather than apples or oranges. Is this possible to do - anyone know any snappy php code to accomplish with a query or some such goodyness?
#2 / Oct 29, 2007 7:18pm
Try an inclusive stack, Rob, e.g.:
category=“4&5”
#3 / Oct 29, 2007 7:24pm
Thanks Derek!! I overlooked that in the docs. That Should do it. 😊
#4 / Oct 30, 2007 2:48pm
I have one instance where ideally I’d like to filter any content by one constant category (Apples) AND several other categories - but don’t want all categories to be stackable:
Want: Apples AND Oranges OR Apples AND Bananas OR Apples AND Cherries
Don’t want: Apples AND Oranges AND Bananas AND Cherries
Any ideas?
#5 / Oct 30, 2007 2:51pm
That’s a bit more complex and can’t be handled by parameters unfortunately. One way that comes to mind is a PHP database query on input to get the entry ids from the exp_category_posts that fit your criteria could be used to generate a list of entry id’s to use in the weblog entries tag’s entry_id= parameter.
#6 / Oct 30, 2007 2:57pm
Thanks for the heads-up! I think we’ll just restructure our content to fit into two categories instead of three.