Display ACF object field data using Elementor Custom Query

The issue can be solved with this code : function my_cpt_query( $query ) { $myPostObjetField= get_field(‘cpt1_field_for_cpt2’,$post_id,false); foreach( $myPostObjetField as $post_field_item_value ) { $ids[] = (int) $post_field_item_value; } $query->set( ‘post_type’, ‘CPT2’); $query->set( ‘post__in’, $ids); } add_action( ‘elementor/query/13600’, ‘my_cpt_query’ );

Elementor Custom Query to get Posts by ACF (Post Object Field

Reference Link: https://developers.elementor.com/custom-query-filter/#Using_the_Custom_Filter arbitrary_name_query_id – the QUERY ID that you fill in the Elementor field, the code to be placed within functions.php: add_action( ‘elementor/query/arbitrary_name_query_id’, function( $query ) { $meta_query = $query->get( ‘meta_query’ ); $meta_query[] = [ ‘key’ => ‘acf_key’, // put ACF relationship field name ‘value’ => get_the_ID(), ‘compare’ => ‘=’, ]; $query->set( ‘meta_query’, $meta_query … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)