Search pages that are a child of the current page

Question

I’m developing my own WordPress theme and I was wondering if it is possible to modify the search query in a way that it only return results that are child pages of the actual page.

The reason I want this is that our site is getting really big and the user should be able to navigate to a parent page and then search for pages in this topic.

I give you an example. Our site is about the chemistry studies and has a page tree of the following form:

  • Home
  • Tipps & Ticks
  • Practical courses
    • Organic Chemistry
      • Synthesis
    • Inorganic Chemistry
      • Proof for anions
        • Sulfide
    • Physical Chemistry

So if the visitor has navigated to the “practical courses” page, the search form should only search for the input on it’s child pages. Same for the subpages of that page.
This would simplify the process of finding the right article enormously as the user can add “filters” by navigating to a specific page.

I’m happy for all answers and ideas.
Regards, Chwebo

0
, , , Sam 8 months 0 Answers 100 views 0

Leave an answer