Support

Account

Home Forums General Issues Get the Unique List of Field Values

Helping

Get the Unique List of Field Values

  • Hi, Please help.

    
    <?php
    $args = array(
    	'post_type'	=> 'post',
    	'numberposts'	=> -1,
    	'orderby'	=> 'title',
    	'order'		=> 'ASC'
    );
    	$query = new WP_Query( $args );
    
    if ( $query->have_posts() ) { while ( $query->have_posts() ) : $query->the_post(); ?>
    	<p><?php echo get_field('region'); ?></p>
    <?php endwhile; } ?>
    

    This code is types a list of ALL region field’s values

    I need a UNIQUE list of field values

  • Hi @vivosystems,

    Thanks for the post.

    I would recommend you store all the values from the get_field() call in an array and then use the array_unique() function to filter the results and remove the duplicates.

    Here is more info on this function: http://php.net/manual/en/function.array-unique.php

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Get the Unique List of Field Values’ is closed to new replies.