global $query_string; $query_args = explode("&", $query_string); $search_query = array(); foreach($query_args as $key => $string) { $query_split = explode("=", $string); $search_query[$query_split[0]] = urldecode($query_split[1]); } // foreach $all = get_posts(array('post_type'=> 'page', 'posts_per_page' => -1)); $parents = array(); foreach ($all as $single) { $kids = get_children($single->ID); if(isset($kids) && !empty($kids) && count($kids) >= 1) { $parents[] = $single->ID; } } $search_query['post__in'] = $parents; $search = new WP_Query($search_query);