Search anything from a Child and Sub-Pages of their Parent page
I am trying to search and want to get results only from the Child - Sub Pages of their parent page. In the following code, I just get results from child pages, not subpages. Please help
Understand the Root:
Parent Page
child 1
sub child a
sub child b
child 2
sub child a
sub child b
child 3
sub child a
sub child b
Note: (When I search anything Results comes only from their child and not from subpages)
Function.php
?PHP
function searchquery($query) {
if ($query-is_search) {
$query-set('post_parent', 16);
}
return $query;
}
add_filter('pre_get_posts','searchquery');
?
html code
form id=search_form method=get class=search_form action=?php echo get_site_url(); ?
input type=text value=?php echo searchquery($query); ? name=s id=s placeholder=Course Name /
input type=hidden value=post name=page /
button type=submit value=Submit search course i class=fa fa-search/i /button
/form