How can I filter the Elementor Posts widget with a custom php query that returns posts with a specific tag attached?
I want to do something similar to this:
function my_query_by_post_types( $query ) {
$query->set( 'post_type', [ 'custom-post-type1', 'custom-post-type2' ] );
}
add_action( 'elementor/query/{$query_id}', 'my_query_by_post_types' );
The line that interests me is:
$query->set( 'post_type', [ 'custom-post-type1', 'custom-post-type2' ] );
But instead of querying post types, I want to query a specific Tag from the "Posts" post type. I'm not familiar with the syntax so I am not sure how to type it in.
elementor/query/{$query_id}
is not a WP filter, and the Elementor posts widget is unique to Elementor. This is an Elementor question. If we pretend this is apre_get_posts
Q as the code implies (which it is not), that is no guarantee it will do what you need it to do either as it's not an equivalent for the recent posts widget. This is an inappropriate place to ask this question, and this is not a place to get help with Elementor.