Use array_unique()
<?php
foreach($users as $user) {
$states[] = get_cimyFieldValue($user->ID, 'STATE'); // Grabing their state from their profile page
}
$states = array_unique($states);
?>
<div class="state">
<input type="hidden" name="search_type" value="members">
<select id="stateDrop" name="state">
<option value="name">State</option>
<?php
foreach($states as $state) {
echo '<option value="'.$state.'">'.$state.'</option>';
}
?>
</select>
</div>
Related Posts:
- A search for ‘0’ returns results
- Endless loop with wp_insert_post and wp_update_post
- Add Incrementing ID to each paragraph in the_content
- post__in – Placing content from a foreach loop inside of an array
- Search widget breaks when using multiple loops?
- If No Search Results, Show Posts from Alternate Search Query
- In a foreach loop, how do I target the last item in the loop?
- How to iterate through database until it find a match
- Custom search form to display users only
- have_posts() execution failure
- How to get an array of years from all of the search results, and use it to filter by year the paginated loop?
- WordPress Search Results for Multiple Post Types
- How to go about combining dropdowns / filter queries?
- Get search.php results in header.php?
- Filter the_posts doesn’t work on search page
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- How to print out menu names in the foreach loop?
- Add class to last 3 posts in loop
- Output meta into arrays
- Need to add class to first element in a foreach loop
- Foreach displays from last to first
- How to modify search.php to not show pages only show posts
- Simple foreach loop help needed in wordpress “the loop”
- Include future posts in tags and in search
- How to print redux gallery feilds id? [closed]
- Search page loop banner image issue
- Does search.php autofilter The Loop?
- Search.php gets metadata from first post
- How to check all items in a loop have post thumbnail?
- How do I set the Stewart Search Template to return only published posts in the result
- Trying to get all links in my posts
- Work arounds for conditional checks inside the loop in search.php?
- what’s the syntax for if the image exists get the image?
- Search – Check if post is a page on search page
- Get featured image outside the loop using foreach
- Why loop renders only last metabox from array? [closed]
- Foundation modal in wordpress php loop
- ACF field not appearing correctly in loop
- Wrap every 2 divs in row – for each loop [closed]
- ACF loops false value with repeater and checkbox
- Retrieve each widget separately from a sidebar
- Where should I use post_class()?
- Woocommerce, recognize the loop of related products
- get_the_foo() in the loop – does it perform another query?
- Check if date of post is yesterday
- Easiest way to show total number of subpages
- Fix inefficient loop breaks post.php on form submit
- Output 2 items within the Loop
- Get Pagination (WP-PageNavi) not to work
- Filtering The Loop For Single Page and Blog Page
- the_content() seems to block my ACF-code
- Can I use HTTP POSTs? Is there a better alternative?
- Pulling current post/page data into header.php
- Loop and Page template : my WP_query don’t take args
- How can I add pagination and how can I change thumbnail size?
- Display post category in foreach loop with category link
- Get single post from tags array
- Apply an Incremental Counter in an Array Function
- List authors with the last post title and order by last post date
- WordPress: Loop Help
- Woocommerce: How to display product price [closed]
- PHP Warning: strip_tags() expects parameter 1 to be string?
- Loop counter style
- Can I add generic numbering HTML classes to items as a loop runs?
- Custom Post Type on Homepage – Studiopress Genesis Framework
- New loop vs widget
- Yoast taking over my WordPress title tag [closed]
- Pagination broken after using 2 loops to show content
- Only show first image in foreach loop
- Wpdb get->results to out the the month from the db
- Getting page slug
- Searching Posts Programmatically in a WordPress Plugin
- Exclude page from loop results
- How is WordPress changing the content markup?
- Get most recent post for every term in a given taxonomy type
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Custom Blog Loop on Home Page
- Open Graph in Index Loop
- Validate search against a list of codes in wordpress
- search.php to search only the post title
- How to add Default Level-0 parent and Level-1 class in WordPress Category in li element?
- Updating Post meta (ACF field) from Feed
- How to add pagination in Terms
- In the php, how can I have a category of a custom post type display?
- A code that I could not fully grasp related to foreach & count_user_posts()
- Include only one category but Exclude if is in a category from loop
- Include search tags and users in my search results system
- Get child taxonomies in loop
- Two loops in one function
- WordPress Multiple Loop: Home/Archives Page, with pagination
- Placing the content of one post in two side by side columns, newspaper style
- One loop for sticky, one for all the rest – how, without specifying category?
- Pass WP post content to a jQuery plugin (Fancybox)
- Query Custom Post Type by Tag
- Showposts doesn’t show the number of posts indicated
- How to refresh a template page on WordPress in 3 seconds – easiest method?
- Implement “No related posts for this entry” into the loop?
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Problem with ms-thumb-frame-selected class in Master Slider
- How can you make it so the comment box shows on some pages or posts but not all?