Home Forums ACF PRO Display sibling ACF fields


Display sibling ACF fields

  • I’m trying to show a list of sibling pages that excludes the current sibling page and includes a few of the ACF fields associated with each sibling page.

    The following is what I am using on the parent page to show all the child pages.

    <!-- PROJECT TILE -->
    <?php $this_page_id=$wp_query->post->ID; ?>
    <?php query_posts(array('showposts' => 20, 'post_parent' => $this_page_id, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
    <div class="col-xs-12 col-sm-6 x-tile">
    	<a href="<?php echo get_permalink(); ?>" class="tile-link">
        <div class="x-tile-image"><img src="<?php the_field('grid_thumbnail'); ?>" class="x-the-tile" /><h2><?php the_title(); ?></h2><img src="<?php the_field('grid_thumbnail_hover'); ?>" class="x-the-tile-hover" /></div>
    <?php } ?>
    <!-- /PROJECT TILE -->

    To be clear, I have a Parent Page ‘Project Type A’, with child pages ‘Project 1’, ‘Project 2’, ‘Project 3’. When I am on page 1, at the bottom of the page I want to display fields from 2 & 3.

    I’ve tried changing the post_parent args to reference the proper starting point but this has failed. Admittedly I’m a php hack. Any help would be appreciated.

  • Hi @cober

    Thanks for reaching out to us.

    You may consider using the post_not_in option in your query as follows .

    'post__not_in' => array($post->ID)

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Display sibling ACF fields’ is closed to new replies.