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
- Different date time in results of search
- What to and how to proceed with CPT to make DB small and efficient?
- woocommerce get_price_html not pulling in correct price
- Make blog page show 10 on first page, 9 on every other page
- Exclude posts from main loop based on meta value
- Blog posts repeat
- How to add condition in wordpress loop? [closed]
- How to inject posts from certain category on home page
- Woocommerce : Can’t get product info in loop
- Trouble Formatting DateTime
- Order archive results by post id in custom taxonomy template
- Using an ACF field from a page within a post loop?
- Duplicate posts in paginated results
- Publish Categories for a particular Author on a given Post
- How to set variable, pass it to a partial file and remove it after?
- how to refresh div on template part?
- Detect if current page is front page within custom query
- Output loop leveraged shortcode twice on one page
- The Loop – mixed ASC and DESC order
- Search not showing all results
- Alter query using pre_get_posts() if meta_key is present
- Next Posts Prev Posts for Standard post format only
- Pagination for multiple loops
- Autocomplete search box
- Counter in loop in foreach
- search suggest – filter post type
- Alert Bar section within WP loop is displaying even though there are no posts
- remove post that has no content
- Display Authors in a grid loop
- trouble calling an import class from an action in a plugin before wp_cron executes
- How to fix pagination for custom loops?
- Display category name only once inside loop
- Infinite Scroll and DFP
- Two loops on different pages do the same thing, but only one page works
- Posts active and expired in different loops
- angularjs not displaying all posts
- Blog page Server error 500 with stick post loop in query.php
- Can’t find infinite loop cause
- Blog’s post count cause irratic behavior
- Checking array against author id in loop
- How do I Turn This Into An if statement?
- pre_get_posts for two loops on same page
- Ajax Button to load more Posts into a timeline
- Sanitize Custom Field Value in Meta Query
- How to make search for posts using get method?
- Default ‘post’ post type archive slug?
- Stuck in the query loop
- How to target thumbnails of the first post in the loop
- show random image in loop if image is not set
- edit search.php to include subdomain posts
- How do I style the first two posts of a loop
- Get Page content to displayin Bootstrap Modal
- WordPress Rewriting the DOM?
- How can I paginate this?
- Obtain page data and use regular loop
- How to display posts by vote count and if no value continue with latest posts with no votes?
- How can I load posts starting from, and including, the current post?
- Load wordpress content in other domain
- Genesis multiple category custom loop 404s after first page
- Custom Loop Using Shortcode in Custom Page Template