Home › Forums › Front-end Issues › Count what select field options was chosen › Reply To: Count what select field options was chosen
Hi @hube2
Sorry, I am using the relationship field in 1 CPT to get data from another (hope that makes sense?)
So I have the loop of CPT (1) and inside that done this;
<?php
$dev_id = get_the_ID();
$doctors = get_posts(array(
'post_type' => 'house_types',
'meta_query' => array(
array(
'key' => 'development_plots', // name of custom field
'value' => $dev_id, // matches exactly "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
if( $doctors ):
?>
<?php
foreach( $doctors as $doctor ):
?>
<?php
$field = get_field_object( 'bedrooms', $doctor->ID );
$value = $field['value'];
$label = $field['choices'][ $value ];
?>
<?php echo $value; ?> //these being 5 5 2 etc.
<?php endforeach; ?>
<?php endif; ?>
Where at the end I was hoping to use the PHP from my previous message to show the min/max of the select fields, e.g.
Min: 2
Max: 5
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.