I am using Elementor Anywhere to create a specific display for my WooCommerce products.
I have a filter and for the filter works I need to use Post blocks Adv.
There I ask to display current archive.
I have the possibility to put a query filter, but I can’t exclude products from a certain category.
I have this, but it doesn’t work with current archives.
function filtrer_produit_sans_crea( $query_args ) {
$query_args['meta_query'] = array(
array(
'key' => '_stock_status',
'value' => 'instock',
),
);
$query_args['tax_query'][] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'coin-des-creatrices',
'operator' => 'NOT IN',
);
return $query_args;
}
add_filter( 'filtre_zero_dechet', 'filtrer_produit_sans_crea' );
Has anyone ever tried something like this?
Or do you have a clue?
2
Answers
OK I found a solution:
But it does on the whole site.
If anyone has a clue how to do it only on a specific page...
Naively I wanted to add this:
But it's doesn't work ^_^
I found another track.
My "page ok" displays well but the function does not launch.
If it is outside this function, the line
add_action('pre_get_posts', 'mystore_pre_get_posts_query');
does what I want it to do.
Is it
add_action( 'wp_head', 'remove_my_action');
that is not the right one?