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 show search results only for a specific custom post type, my code is simple and I already tested it successfully on some wordpress sites I made, but in this case (buddypress) looks like it is not working.

Here is my form:

<form id="vendor-search" action="<?php bloginfo('siteurl'); ?>" method="get">
<h5>Search for vendors</h5>
    <input type="hidden" name="post_type" value="vendors" />
    <label for="s" class="screen-reader-text">Search for:</label>
    <input type="text" id="s" size="23" name="s" value="" />
    <input type="submit" value="Search" id="searchsubmit" />

So I set this hidden input:

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

and then I get a correct URL when searching, something like:


but on displayed results it is including all kind of posts and pages...

Any ideas about what can this be?

Thanks a lot!

share|improve this question

Check out customizing the WP template search.php... you could detect the custom post type query and build your query inside the search.php template as needed.

IF query = custom post type THEN

Customize query using WP_query


Show Standard search results


Hope that helps.

share|improve this answer
Yes, that might work, let me check on this and get back to you. Thanks! – Jaypee May 29 '12 at 17:31
Hmmm, I'm trying several ways, but can't get the right code, would you mind to give me a clue of how I should set? I've never customized a search. – Jaypee May 29 '12 at 17:56

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.