Add to theme functions file:
function exclude_specific_posts_from_search($query) {
// Check if it's a front-end search query (not admin)
if ($query->is_search && !is_admin()) {
// Replace 123, 456 with your page/post IDs to exclude
$excluded_ids = array(123, 456);
$query->set('post__not_in', $excluded_ids);
}
}
add_action('pre_get_posts', 'exclude_specific_posts_from_search');






