A
A
Andrej Sharapov2018-09-21 08:54:24
WordPress
Andrej Sharapov, 2018-09-21 08:54:24

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

2 answer(s)
I
id_baton4eg, 2018-09-21
@id_baton4eg

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

I
Igor Vorotnev, 2018-09-21
@HeadOnFire

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 question

Ask a Question

731 491 924 answers to any question