Support

Account

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(). ?>