Home › Forums › ACF PRO › Get siblings via parent relationship. › Reply To: Get siblings via parent relationship.
It’ so interesting so – the code below is the reverse relationship query minus the (for lack of better terminology) internal relationship query. This works flawlessly, and finds the parent, without interrupting the current post’s data.
<ul class="package">
<?php
$args = array(
'post_type' => 'page',
'meta_query' => array(array(
'key' => 'package-creator',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
));
$getmysiblings = new WP_Query($args) ?>
<?php if ($getmysiblings->have_posts()): ?>
<?php while ($getmysiblings-> have_posts()): $getmysiblings->the_post(); ?>
<?php // get the relationship field ?>
THIS IS WHERE THE RELATIONSHIP QUERY SHOULD GO.
<?php // end get relationship field ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<?php endif; ?>
</ul>
I’ve tried using both variations of the relationship query inside of the above marked area – and both ways it works, but corrupts the content of the provided page. (which btw, is retrieving ACF fields not just post content) I’ll keep working on it.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.