Support » Fixing WordPress » Logical AND …. “? cat=x&cat=y”

  • Hi community or whoever reads this,
    I´ve got a question resp. the behaviour of the query.
    Trying to use two category expressions in one query, e.g. index.php?cat=11&cat=12 does neither work as OR or AND but yields only the last “cat”-expression, in this case all posts in “12”. I would like to know whether it´s possible to have the above query getting to work as Logical AND function, giving back only those entries that belong to both those categories .
    Thanks for any (valuable) input !
    Jonas / Germany

Viewing 12 replies - 1 through 12 (of 12 total)
  • try cat=12,13

    Thanks for the reply, but the function only reads the one value after the “=” in the query…Helpful would be some insight given to me by some WP-crack whether “AND” for ‘n’ cat queries is working at all or how it could be enabled..

    The method that chuyskywalker described works but does an OR on the categories. So cat=11,12 would display posts from categories 11 or 12.
    As far as I know, there isn’t a way to diplay only posts that belong to two specific categories. Are you sure you want what you’re asking for? This would be like asking for posts from “Football” and “Vacation” categories.

    Well, a Select of post in two disjunct categories is quite important for my purposes. I am maintaining a business weblog and make very extensice use of categories. I have for instance news items that stem from a specific country, contain news of a specific supplier or contain business figures . Being able to use a .php?cat=n&cat=y&cat=z query would enable me (and others with a similar subject) to build a very interesting category-based search.
    Thx for follow up



    Try using a plus sign:



    Thanks for reading&replying, but I am afraid that does not work either…but thx anyway



    in the top of you index.php, right after the notice about not removing these lines, try this:

    if (!isset($cat)) {
    $cat = "x,y";

    Where x & y are the category numbers you do want shown.
    See if that works for you.



    I just tested mine (1.2) again and I can do
    and it works perfectly.

    I just tried it, and it does not work for me, either. BTW: I’m very interested in having this feature because I use the blog engine as a sort of poor-man’s bug tracker. Consequently, I need ANDing of categories.

    However, I don’t think I’m running the latest version, so that could be it…?

    dooglio, using either




    to combine category queries has worked from the start. Keep in mind if one of the queried categories has the lion’s share of recent posts, that can make it appear as if it doesn’t work.

    Well, ?cat=1,2,3 and ?cat=1+2+3 does the same thing for me. And that’s not what he’s asking for.

    I too need to be able to get the posts that belong to, say, both cat 2 and 7. I don’t want those that only has cat 2, or only cat 7, but those that has both.


    Let’s say I have categories HOWTO (1) and GIMP (2) and AMAROK (3). Some posts are about GIMP or AMAROK in general, some are GIMP HOWTOs and some might also be AMAROK HOWTOs.

    Now, what I want is GIMP HOWTOs. Asking for ?cat=1+2 gives me all GIMP postings and all HOWTO postings (including AMAROK stuff). How can I get just the postings belonging to both GIMP and HOWTO?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Logical AND …. “? cat=x&cat=y”’ is closed to new replies.