logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$30
Want search to redirect to a page and display specific results

Hello,

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:

Development Site

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
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: Pastebin
Link to my custom post type page php: Pastebin

Thank you,
Dave

This question has been answered.

Dave Schmidt | 11/16/11 at 1:09pm Edit

Previous versions of this question: 11/16/11 at 9:16pm

(2) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    11/16/11
    1:44pm
    Luis Abarca says:

    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.

    http://casselton.com/dev/?s=test&post_type=community_listing

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

    Previous versions of this answer: 11/16/11 at 1:43pm | 11/16/11 at 1:44pm

    • 11/16/11 2:25pm

      Luis Abarca says:

      Something like this ?

      http://casselton.com/dev/community-directory-categories?q=adm

    • 11/16/11 2:27pm

      Dave Schmidt says:

      Yes, I think that woud work just fine.

      Dave

    • 11/16/11 3:03pm

      Luis Abarca says:

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

    • 11/16/11 3:15pm

      Dave Schmidt says:

      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.

      Thanks!
      Dave

    • 11/16/11 3:28pm

      Luis Abarca says:

      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

    • 11/16/11 3:40pm

      Dave Schmidt says:

      Luis,

      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!

      Thanks,
      Dave

    • 11/16/11 3:46pm

      Luis Abarca says:

      Yep Dave

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

  • avatar
    Last edited:
    11/16/11
    1:49pm
    Sébastien | French WordpressDesigner says:

    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 ?

    • 11/16/11 1:53pm

      Dave Schmidt says:

      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: community-directory-categories

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

      Thank you for replying!

      Dave

    • 11/16/11 1:59pm

      Sébastien | French WordpressDesigner says:

      oki understand
      and each result is composed by what ?

      in your page i see


      AGRICULTURE

      ADM Edible Bean Specialities
      1804 Front St. Casselton, ND 58012 347-5321
      thomas.stadler@adm.com www.adm.com

      Dalrymple Farms
      710 Front St. Casselton, ND 58012 347-4291
      www.fargo-history.com/early/dalrymple.htm





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

    • 11/16/11 2:04pm

      Dave Schmidt says:

      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.

    • 11/16/11 2:21pm

      Sébastien | French WordpressDesigner says:

      and you want an url like that

      http://casselton.com/dev/community-directory-categories?s=bonneville

      or like that

      http://casselton.com/dev/community-directory-categories

      for the result of the search "bonneville"

      ?

    • 11/16/11 2:27pm

      Dave Schmidt says:

      I think http://casselton.com/dev/community-directory-categories?s=bonneville would probably make more sense.

      Thanks,
      Dave

    • 11/16/11 2:30pm

      Sébastien | French WordpressDesigner says:

      so i think that you have your solution :
      http://casselton.com/dev/community-directory-categories?q=adm
      :-)

This question has expired.



Gabriel Reguly, Julio Potier, Francisco Javier Carazo Gil, Dave Schmidt voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.