add_action( 'elementor/query/related_industry_insights', function( $query ) {
if ( !is_singular('industries') ) {
return;
}
// Get selected terms from ACF taxonomy field
$terms = get_field('related_industry_insights'); //your ACF field name
if ( $terms ) {
$term_ids = array_map( function( $term ) {
return $term->term_id;
}, $terms );
$query->set( 'tax_query', array(
array(
'taxonomy' => 'industry-category', // your taxonomy slug
'field' => 'term_id',
'terms' => $term_ids,
),
));
// Order by latest (most recent first)
$query->set( 'orderby', 'date' );
$query->set( 'order', 'DESC' );
} else {
// Optional: show nothing if no category selected
$query->set( 'post__in', array( 0 ) );
}
});