I am trying to query any post which has a certain post_object selected as its "parent". The parent value will have to match the ID of the current post. I have been able to replicate this functionality by querying all posts of this post type and then comparing the values within the loop, like so:
<?php
$wp_query = new WP_Query();
$wp_query->query( array (
'post_type' => 'my_post_type',
'meta_key'=>'post_object_field'
));
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
$parent = get_field('post_object_field');
$parentId = $parent->ID; ?>
<?php if ($postId == $parentId): ?>
// content
<?php endif; ?>
<?php endwhile; endif; ?>
I'm wonder if there is a way to check for this value inside the query, and if so, if it's any faster or more correct.