Home › Forums › General Issues › Querying a Post Object relation field inside a repeater › Reply To: Querying a Post Object relation field inside a repeater
Thanks for pointing me in the right direction. I tried taking that and modifying it for my needs, but I’ve made it so incredibly wrong.
One issue, I think, so that I’m not properly telling it to “go to People custom post type, look for the person_department repeater field, and then give me the value for person_departmetn_select subfield -if- person_department_head field checkbox subfield is checked.”
Here’s what I have so far…
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'people',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'person_department_select', // this should be the first sub-field
'value' => get_the_ID(),
'compare' => '='
),
array(
'key' => 'person_department_head', // this should be the second sub-field
'value' => true,
'compare' => '='
)
)
);
// query
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
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.