Support

Account

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.