Answer the question
In order to leave comments, you need to log in
How to set up site search on specific pages?
Hi all!
Tell me how to build a search form so that the output on the results page is only for a given "section".
Explanation.
There is a "website/page(s)/sub_pages", you need to make your own form for "/page(s)/..." so that for a given request, the serp contains pages of only this "section (/parent page/pages)" .
Answer the question
In order to leave comments, you need to log in
make an extra input and pass its parameter, where identifiers or search taxonomies will be specified. You can also implement it by creating your own "filter" based on the usual form + ajax + wp_query
1. The pre_get_posts hook
2. Isolate the search query with $query->is_search()
3. Set additional required query parameters with $query->set()
Everything is in the documentation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question