Plugin Support
Karan
(@kjswp)
Thank you for sharing your positive feedback.
We’re glad to hear that you’ve found the SearchWP Live Ajax Search plugin useful for your site.
Regarding your query, I would like to clarify that the free Live Ajax Search plugin uses the default WordPress query to find results. Because of this, you can use another plugin, such as Search Exclude to remove any post or page from appearing in the live search results.
Additionally, you can use the following custom code to exclude all pages from search:
function exclude_post_types_from_search($query) {
if ($query->is_search()) {
$excluded_post_types = array('page'); // Replace with post types to exclude
$post_types = get_post_types(['public' => true], 'names');
$query->set('post_type', array_diff($post_types, $excluded_post_types));
}
}
add_action('pre_get_posts', 'exclude_post_types_from_search');
This is what I need! Thanks