title: Fixing custom query for wordpress/elementor with Advanced Custom Fields relationship field post types
body: <p>I was wondering if someone could help me out.
  I can't seem to get this case working (since I am a noob in PHP).</p>
  <p>Case:
  My wordpress site has <strong>two 'post types'</strong>:</p>
  <ul>
  <li>Webinar</li>
  <li>Spreker (speaker in dutch)</li>
  </ul>
  <p>Via Advanced Custom Posts i've set up a relationship field in the webinar post type. So I can pick the speakers related to that particular post.</p>
  <p>I use elementor and need to use the elementor's post widget to display the related speaker(s) via the single webinar page template. This has to be done by a custom query. In elementor you can set a custom query ID. This calls for a php query code.</p>
  <p>Now I can't seem to get this query array code right.</p>
  <p>Elementor documentation about custom queries:
  <a href="https://developers.elementor.com/custom-query-filter/#Using_the_Custom_Filter" rel="nofollow noreferrer">https://developers.elementor.com/custom-query-filter/#Using_the_Custom_Filter</a></p>
  <p>Some related answers on internet (but can't still seem to get it working):
  <a href="https://stackoverflow.com/questions/63923768/custom-query-filter-for-elementor-posts-by-relationship-field-acf">Custom Query Filter for Elementor Posts by relationship field (ACF)</a></p>
  <p><strong>The custom query ID i use in Elementor is 'Spreker_filter'</strong></p>
  <p>My code:</p>
  <pre><code>add_action( 'elementor/query/spreker_filter', function( $query ) {
  // Get current meta Query
  $meta_query = $query-&gt;get( 'meta_query' );
  
  // If there is no meta query when this filter runs, it should be initialized as an empty array.
  if ( ! $meta_query ) {
  $meta_query = [];
  }
  
  // Append our meta query
  $meta_query[] = [
  'key' =&gt; 'sprekers',
  'value' =&gt; '&quot;' . get_the_ID() . '&quot;',
  'compare' =&gt; 'in',
  ];
  $query-&gt;set( 'meta_query', $meta_query );
  } );
  </code></pre>