pseudo visitor
Participant
5 years, 5 months ago #8656
It’s basically the same code.
It was kinda stupid on my side, but I forgot that I was experimenting with the plugin’s hooks yesterday, so I had some spread out throughout the website. That’s why it was giving me that error I sent you. When I removed that, I just used the code I’m leaving you below in my theme’s functions.php and it worked correctly ????
use wpsolr\core\classes\WPSOLR_Events;
use wpsolr\core\classes\WpSolrSchema;
add_action(WPSOLR_Events::WPSOLR_ACTION_SOLARIUM_QUERY, 'wpsolr_action_query', 10, 1);
function wpsolr_action_query($parameters)
{
/* @var WPSOLR_AbstractSearchClient $search_engine_client */
$search_engine_client = $parameters[WPSOLR_Events::WPSOLR_ACTION_SOLARIUM_QUERY__PARAM_SOLARIUM_CLIENT];
$taxonomy_name = 'tax-name';
/** * Create a "not exists" filter */
$filter_not_exists_terms_in_taxonomy = $search_engine_client->search_engine_client_create_not($search_engine_client->search_engine_client_create_filter_exists($taxonomy_name . WpSolrSchema::_SOLR_DYNAMIC_TYPE_STRING));
$search_engine_client->search_engine_client_add_filter("not in taxonomy {$taxonomy_name}", $filter_not_exists_terms_in_taxonomy);
}
And again, thanks a lot for your help!