Exclude taxonomies
-
Hi,
I use elasticsearch in Author and Search Page in the main site of a Network.
I need to exclude a term of taxonomy from elastic search queryadd_action('pre_get_posts', function($query){ $query->set('ep_integrate', false); if ($query->is_main_query() && ($query->is_search || $query->is_author)) { $query->set('ep_integrate', true); $query->set('tax_query', array( array( 'taxonomy' => 'MYTAX', 'terms' => array('no-index'), 'field' => 'slug', 'operator' => 'NOT IN', ), )); } }, 999);
This doesn’t work!
So i’m trying with another filter
add_filter('ep_index_posts_args', function ($args){ $args['tax_query'] = array( array( 'taxonomy' => 'MYTAX', 'terms' => ['no-index'], 'field' => 'slug', 'operator' => 'NOT IN', ), ); return $args; }, 0, 1);
But it seems doesn’t work!
Obviously the term ‘no-index‘ exists in all sites (differente term-id, for this reason i use the slug).
Without ep_integrate filter works!How can i solve this problem?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Exclude taxonomies’ is closed to new replies.