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'm trying to build an advanced search form by post type.

For example...

I have custom Post Type : Locatie Taxonomy : locatii

I have categories in PostType :


-Orase - Arad - Alba....

-Tip - Puncte de livrare - Gaze Medicale

I want to get all post in that categories..

For example i select Arad and Gaze Medicate... and shoud apear me all the Medical Point for city arad.

<form method="get" name="searchform" action="<?php bloginfo('url'); ?>/">

<legend>Centre de distributie:</legend>
<table width="500" border="0" cellpadding="0">
    <td width="135"><b>Selecteaza oras :</b></td>
    <td width="359"><select name="locatie">
<option value="alba">Alba</option>
<option value="arad">Arad</option>
<option value="arges">Arges</option>
<option value="bacau">Bacau</option>

<div class="ti"><b>Limiteaza cautarile</b></div>
<div class="linie"></div>

<table width="500" border="0" cellpadding="0">
    <td width="20"><input name="produs" value="1" type="checkbox"></td>
    <td width="160">Punct de livrare</td>
    <td width="25"><input name="produs" value="1" type="checkbox"></td>
    <td width="109">Parteneri logistica</td>
    <td width="35"><input name="produs" value="1" type="checkbox"></td>
    <td width="137">Agenti</td>
    <td><input name="produs" value="1" type="checkbox"></td>
    <td>Gaze Medicale</td>
    <td><input name="produs" value="1" type="checkbox"></td>
    <td><input name="produs" value="1" type="checkbox"></td>
<div class="sub">
<input class="art-button" type="submit" name="search" value="<?php _e('Search'); ?>" />

share|improve this question

In your search form, add an input with name="post_type" and value="customposttypehere".

You can either have this as a hidden input or a text entry or a combobox or radio buttons etc, so long as it's inside the search form.

The same is true for any other query vars like post_type etc that you would normally put in WP_Query

share|improve this answer

You'll need to look into pre_get_posts(). A great starting tutorial on this is by Pippin Williamson, Using pre_get_posts to Modify Queries for Meta Data and More (helped me out immensely).

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.