Hi @mattschofield,
We have a setting for that. You can configure the Live Search elements within the Customizer settings simply by navigating to Customize > Header Builder > Search and selecting the ones required. Here’s a screenshot to guide you with a visual reference.
Kind regards,
Aradhy 😊
Hi @bsfaradhy
Thanks for the reply. However, that’s not what I meant. It would be very useful to be able to exclude specific posts ID’s from the live search results.
I’ve been trying to find the filter Astra uses for its live search AJAX requests, so I could write my own snippet for specific post ID exclusion, but I’m struggling to understand how Astra is handling it.
I got it. I was over complicating things. I’ve managed to exclude specific pages and posts by their post ID from Live Search Results using the following php snippet:
/**
* Exclude specific post IDs from WordPress search results.
*/
function exclude_posts_pages_from_search( $query ) {
if ( $query->is_search() && ! is_admin() ) { // Check if it's a front-end search.
$excluded_post_ids = array( 245, 3860, 3864, 3862, 7930, 9943 ); // Replace with your post/page IDs.
if ( ! empty( $excluded_post_ids ) ) {
$query->set( 'post__not_in', $excluded_post_ids );
}
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_posts_pages_from_search' );
Please consider providing this granular control for Live Search Results in Astra. Thanks again for looking.
Hi @mattschofield,
Thank you for the update and I’m really glad to hear you figured it out! That’s a neat solution, and I’m sure it’ll be helpful for others with a similar use case.
We appreciate your suggestion regarding more granular control over Live Search Results. Since this leans more toward a custom requirement, it might not be something we implement right away. However, we’ll definitely keep it in mind and consider it if we receive more requests along the same lines.
If your issue is resolved, feel free to mark the thread accordingly. And, of course, we’re always here if you need further assistance!
Kind regards,
Aradhy 😊
Marked as resolved. Thanks
Hi @mattschofield,
Thank you for the update. If you ever need any further assistance, feel free to reach out. We’re always here to help.
Have a great day ahead!
Kind regards,
Aradhy 😊