WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to search in two categories without using the search box at all.

So far, I have this code to display the desired categories,

<?php wp_dropdown_categories('child_of=3&hierarchical=1&depth=1&hide_empty=0&name=cat[one]'); ?>
<?php wp_dropdown_categories('exclude=3&hierarchical=1&depth=1&hide_empty=0&name=cat[two]'); ?>

I have names as array cat as I wanted them to GET from URL and build custom query. I have tried many things but failed.

I just want the user to just press search and it should display posts that are in "Both" categories.

Please help. Thanks.

share|improve this question

Basically you don't really want search, but separate page that will list post on specific condition?

You can create template for a page with Loop that will query for posts, belonging to both categories, using category__and parameter.

share|improve this answer
ok, great suggestion, I did it and its what I needed. Thanks again. – user2497 Jan 14 '11 at 13:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.