Support

Account

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