Hi there. Built a page with X, but search only returns results if the term was in the title of the page. Any ideas as to how to allow the search function to access the page text?
Thanks.
Hi there. Built a page with X, but search only returns results if the term was in the title of the page. Any ideas as to how to allow the search function to access the page text?
Thanks.
Hi David,
Please install and activate the child theme and login through FTP then edit the functions.php then add this code:
function wp_search_filter( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', array('post','page') );
}
return $query;
}
add_filter('pre_get_posts','wp_search_filter');
Hope this helps.
Hey Jade,
Thanks for the suggestion. I added that in the functions.php in the child theme after the only existing function but still, I’m not able to locate text in pages. Any other ideas?
Thanks in advance.
Hi David,
That would require customization to make the search more effective, example https://wordpress.stackexchange.com/questions/173193/how-to-search-for-posts-in-or-title-or-content-or-author
But, it may still not work if your pages and post are created to builder’s v2 elements. It’s a known bug and there is no current workaround. That’s because v2 element’s content aren’t accessible outside it, please stay tuned for the future updates and fixes.
Thanks!
Thanks for the info.
I’ll stay tuned. I’d hope that that comes soon as most of my users expect that they can search for a term in a page and not necessarily in the title of the page and get a result.
All the best!
-David
You’re most welcome! And noted 
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.