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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.