Home › Forums › General Issues › How to pull in a record if multiple selections were made › Reply To: How to pull in a record if multiple selections were made
Sorry the code didn’t show up correctly.
<?php
// args
$args = array(
'numberposts' => -1,
'posts_per_page' => -1,
'post_type' => 'staffinfo',
'meta_query' => array(
'relation' => 'AND',
array(
'meta_key' => 'class_level',
'meta_value' => 'administration',
'compare' => '='
),
array(
'meta_key' => 'class_level',
'meta_value' => 'high',
'compare' => '='
)
)
);
// get results
$the_query = new WP_Query( $args );
$i = 1;
// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="staff-member">
<img src="<?php echo get_field('staff_photo'); ?>" alt="<?php echo get_field('staff_member_name'); ?>" />
<div class="staff-info">
<span class="teacher-name"><?php echo get_field('staff_member_name'); ?></span><br />
<span class="duties"><?php echo get_field('classes_taught'); ?></span><br />
<?php if (get_field('email_address')) {?>
<a href="mailto:<?php echo get_field('email_address'); ?>"><?php echo get_field('email_address'); ?></a><br />
<?php } ?>
<?php echo $phone ?>
<?php if ( get_field('phone_extension')) {?>
- Ext. #<?php echo get_field('phone_extension'); ?>
<?php } ?>
</div><!--end staff-info -->
</div><!-- end staff-member -->
<?php if ($i % 5 == 0) { echo "<div class='clearboth'></div>"; } $i++; ?>
<?php endwhile; ?>
<?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.