In the archive page, I would like to show in a loop grid widget ONLY the posts that belong either to the displayed archive category and also to a specific category which slug is "special-one", meaning that they have to be from both categories (operator AND). So I have set up an archive page template in Elementor theme builder. Just in that single loop and not as default for the archive page.
I Used the following code:
add_action( 'elementor/query/special_archive_filter', function( query )
if ( is_category() )
$category_id = get_queried_object_id();
$special_category_id = special-one;
$categorie query->set( 'tax_query', array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => array( category_id,special_category_id ),
'operator' => 'AND',
),
));
}
});
But this code is not giving me the expected result. What I am doing wrong?