Replies: 0
Hi,
The Shipping & Returns post is appearing in the blog even though it is Search Excluded.
https://bansuribliss.com/blog
I added the following code to Fluent Snippets to fix the issue but it doesn’t work.
What do you suggest?
Thanks!
add_action('pre_get_posts', function ($query) {
if (!is_admin() && $query->is_main_query() && $query->is_archive()) {
$search_exclude_ids = get_option('sep_exclude');
if ($search_exclude_ids) {
$posts_not_in = $query->get('post__not_in', array());
$query->set('post__not_in', array_merge($posts_not_in, $search_exclude_ids));
}
}
});