Thank you very much for your answers!
I finally found what I wanted here : http://sixrevisions.com/wordpress/custom-fields-search/
Here is the code :
<form name="search" action="" method="get">
<select name="City">
<?php
$metakey = 'city';
$cities = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );
if ($cities) {
foreach ($cities as $city) {
echo "<option value=\"" . $city . "\">" . $city . "</option>";
}
}
?>
</select>
<input type="submit" value="search" />
</form>
This is a brilliant article and it helped me a lot! I hope it’ll help others too.
Related Posts:
- Order get_terms() By Custom Field
- get_field not displaying my custom field value
- Add extra fields to Add New Category page
- Need help adding custom field to category
- adding custom fields to next and previous post link
- Custom query with category exclusion and post-meta “whitelist”
- Sort category page with custom field
- Create a full width responsive header image per page
- Return category slug / title from category ID
- Filter out posts before display category count
- How to put enctype=”multipart/form-data” in categories form?
- Add custom taxonomy under the category title
- How to call custom category field data in theme?
- query in category.php repeats itself
- need to add custom field in more products
- Retrieving category’s color with get_term_meta
- How to change a post category when the ACF datepicker Field is today
- Listing Texts of Which Custom Field is Null
- How to “group” (categorize) the Pages together?
- How to query categories with Advanced Custom Fields?
- How to add custom color fields to the category edit page?
- Notice: Trying to get property of non-object in : custom fields category
- “Virtual category page” based on a custom field filter
- ACF no print data [closed]
- Displaying a custom field in Category Archives
- Assign a custom post to a custom taxonomy based on custom field value
- Custom Fields Value As Taxonomy
- Update custom category fields front-end
- What is the best way to add an advanced / intermediate / beginner tag to a post
- Show posts from category specified using a custom field
- Adding tinymce to Custom Field boxes on Category edit page
- How can i add service category here? [duplicate]
- Sort categories by custom field in WordPress admin
- Modifying category order
- Displaying data from custom fields on a specific category page
- How can I add different custom fields for each category in the same post?
- How to display custom fields as table in Woocommerce
- How to modify custom category field from front end?
- Ajax Category add doesn’t update the list table custom column
- How to Manage and link certain custom taxonomy?
- Custom field picture instead of post thumbnail on category page
- How to loop through a custom field for each post, & display?
- $args Orderby The number
- ACF plugin categories bug in WordPress 3.9
- Formating content in category.php
- Logic for Nearby places with post and categories
- Sort categories by meta value
- How to structure Multisite sites into categories?
- Custom Fields to Category edit page, then displaying them in a template correctly
- How do I add and display a custom image field to a category? [duplicate]
- Converting Categories (with ACF fields) to custom taxonomies
- How Do I Add HTML Support to the Additional Category Description Field?
- Add custom text in second paragraph of posts in specific category
- How would I get a taxonomy/category list inside a Gutenberg block?
- Echo one category as title when post has multiple categories?
- Showing all the posts in one page?
- On Category page, How can I get the category ID?
- How to order categories in Woocommerce that are spread over multiple pages? [closed]
- Automatically add product_categories to nav_menu
- Can paginate_links() be customized for a specific category or tag?
- Add Product categories to WordPress menu without losing hierarchy
- How to set up Author archives with sub category URL
- How to change number of items on add new pluggins page from backend?
- Ignoring a category in WP_Query still shows the links in next_post_link()?
- Implementing a tricky wordpress menu (nested categories + thumbnails)
- How can I duplicate categories and tags?
- How can I add more “filters” to my products? (Categories, attributes, etc.)
- Removing post category base giving Error 404
- Is There a Difference Between Taxonomies and Categories?
- Related Tags not in category
- Redirect Changed Permalink on wordpress
- Show parent categories and sub categories but not grand children categories
- Grandchild Term Things Grandfather Term is It’s Parent
- Home Page Template – Specific Category
- Same menu for different taxonomies to reach different content
- List all posts of certain category which share some tags
- Search form options group categories
- Natural sort / ordering wp_dropdown_categories
- Make wp_dropdown_categories into a variable that persists until changed?
- show category in woocommerce
- Best way to categorize/populate a magazine style layout
- Mass Update User Profile Checkbox Options
- Category sticky latest
- How can I exclude a category from the main loop with the category name & not ID?
- how to remove alphabetical order of category in WordPress?
- How to list posts from a sub-category that is listed in a parent category (more details below)?
- How to exit out of delete_categories and stop action?
- Meta Query | Compare category name and meta value
- How to filter tags by category?
- How Can I Display the Category Description in a Theme with no Category.php or Archive.php?
- WooCommerce – Get products from category right before deleting category
- omit categories from main navigation menu
- How to relocate images
- Category next page link not working
- How to display the past events in one of the category?
- Page Type with Category Link
- If I change the taxonomy of a post will it get a new time stamp?
- Display post of current parent category, and in right hand side show child category post
- Category pagination not working in category.php please help me
- Print the associated categories of the current post starting with parent (with option to remove href)