Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

mywebsite.com/?post_type=vendors&s=Marketing

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
add comment

1 Answer

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

ElSE

Show Standard search results

END IF

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
add comment

Your Answer

 
discard

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.