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

Want search to redirect to a page and display specific results WordPress



I'm building a website for a city that has a community/business directory. I've added a custom post type for the directory listings, and now need an elegant way to search those listings. Here is the link:

[[LINK href=""]]Development Site[[/LINK]]

We have a search bar in the top right corner, and when a visitor enters a value we'd like the following to happen:
1. Redirects to [[LINK href=""]][[/LINK]]
2. Only searches the business names and categories on this page (no other posts or pages, etc.)
3. List the search results (which I can style)

Does anyone have experience with this?

I'm using the default WordPress searchform.php
Link to my search.php: [[LINK href=""]]Pastebin[[/LINK]]
Link to my custom post type page php: [[LINK href=""]]Pastebin[[/LINK]]

Thank you,

Answers (2)


Luis Abarca answers:

Hi schmidty54, as i undertand you just only need to filter the search result to a specific post type.

You can add a hidden field with your post type in your search form to get a ulr like this.

[[LINK href=""]][[/LINK]]

i can help with this if you send me login/ftp details via PM.

Luis Abarca comments:

Something like this ?

Dave Schmidt comments:

Yes, I think that woud work just fine.


Luis Abarca comments:

I'm glad it helps Dave, let me know if you have any issue

Dave Schmidt comments:

Hi Luis,

I see you've been able to redirect the search. That's great, and thank you!

Are you able to help me add my custom taxonomies to the search query? So I just want the visitor to be able to search my custom post types and custom taxonomies.


Luis Abarca comments:

OK Dave.

As we are using a custom page for the search, we can add that filters in in the args of WP_Query, we need to pass the post_type argument when we use the default search Wordpress

Dave Schmidt comments:


For an extra $10 can you write the query for me?

Right now I just copied and pasted search code from Ian Stewart's blog. I pasted the code on the custom page. I'm just not that comfortable writing custom queries. All I really want is the following:

1. Text that reads: "Search Results for: " with the search term displayed.
2. Results based on either category or post title.

We're soooo close Luis! I'm sure you can help me with this!


Luis Abarca comments:

Yep Dave

I'm trying to edit the files, but it seems you moved the folder to another place :S


Sébastien | French WordpressDesigner answers:

Dave, i'm french. So i need to know if i understood your question.

You want a specific page "result of search" which displays only the business names and categories (no others pages)

That's it ?

i dont understand the first point "redirects to".
And the third ("List the search results"). Is it not the same thing ofthe point 2 ?

Dave Schmidt comments:

Hi Sébastien,

Once you type in your search query and press enter (or click on the magnifying glass), I'd like WordPress to take the visitor to this page: [[LINK href=""]]community-directory-categories[[/LINK]]

I'd like the search results to display on this page, not the typical search page. So if you look at [[LINK href=""]]community-directory-categories[[/LINK]], I'd like the search results to appear above the content. Does that make sense?

Thank you for replying!


Sébastien | French WordpressDesigner comments:

oki understand
and each result is composed by what ?

in your page i see


ADM Edible Bean Specialities
1804 Front St. Casselton, ND 58012 347-5321
[email protected]

Dalrymple Farms
710 Front St. Casselton, ND 58012 347-4291

what is "agriculture" ? a categorie ?
"ADM Edible Bean Specialities" is a title
athers informations are values of differents custom fields, that's it ?

Dave Schmidt comments:

Agriculture is a custom taxonomy named "listing_category".
ADM Edible Bean Specialities is the title of a custom post type named "community_listing".
And yes, the information being populated is added via custom fields.

Sébastien | French WordpressDesigner comments:

and you want an url like that

or like that

for the result of the search "bonneville"


Dave Schmidt comments:

I think would probably make more sense.


Sébastien | French WordpressDesigner comments:

so i think that you have your solution :
[[LINK href=""]][[/LINK]]