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'); ?>" />


2 Answers 2


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


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).

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .