Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Individual custom post type search form WordPress


I need a code to create a search form that only search on one custom post type I want, and also display the result in the same page (is using a template) not on search.php.

I mean, the custom post type I create is companies, and want the user can make a search in the companies page (it use companies template that shows only companies custom post types) and the result of they search only shows companies not post, pages or other kind of content.
Hope with this is more clear. :P

Answers (2)


rhand answers:

Here is a [[LINK href=""]]link[[/LINK]] to a similar discussion. You could create a page template for a custom search page and use WP_Query to grab search results you need. See also


Pali Madra answers:

Use this code and it should work if there is one custom post type.

<input type="hidden" name="post_type" value="post type name" />

Let me know if this works!

Pali Madra

Pancho Pérez comments:

One and only?, and where the result will show ?