• Dear fiend

    Please help me to code search form filter :
    I have field type :select width more select fiel_name list, how to customs search by field name from category ID=1 .

    thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    If you setup your form so the search field is named “s” and there’s a hidden field named “cat” with a value of 1, form method GET and action to your installation’s index.php, you end up with an URL something like yoursite.com/index.php?s=search%20term&cat=1, which would run your desired query without any real coding other than setting up the HTML form correctly.

    Thread Starter qdungeng

    (@qdungeng)

    Dear friend

    How to create page for this search results ?

    Now all results in search.php

    Please help me.

    Moderator bcworkz

    (@bcworkz)

    You can create a template file that meets your needs. Then hook the ‘template_include’ filter and check the global $wp_query for the “s” query var having any value and the “cat” query var equal to 1. If so, return the path to your template. Your template will then be used to display the results, provided it runs the “Loop”.

    Another approach, which you may have had in mind to begin with, is to create a custom page template. If the page is requested via GET, display a search form. The form method is set to POST. If the page is requested via POST, that means a search has been requested. The search term is used to construct a query along with ‘cat=1’. The DB is queried and the results displayed via the “Loop”.

    Then simply add a new page based on this template. Provide a title and publish the page. No content is needed unless the template is designed to make use of such data. Then anyone that wants to use this search form uses the page’s permalink to access the form.

    Thread Starter qdungeng

    (@qdungeng)

    I do not know how to coding,

    this search /?s=hanoi&term&cat=5

    How to get results without search.php

    Thanks

    Thread Starter qdungeng

    (@qdungeng)

    How to use is_search in search.php for a cat=1 search results.

    Thanks

    Moderator bcworkz

    (@bcworkz)

    Hi qdungeng,
    If you are unable to do most of your own coding, I cannot help you, I’m sorry. I left your posts unanswered for a while in the hopes someone else could help you, but it’s not looking promising.

    Without coding, the approach mentioned in my first response is your best option. It will go to search.php, which can’t be helped without doing any coding. is_search() serves no purpose on search.php. It will always return true because only searches go to that page.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to search by field from ACF’ is closed to new replies.