You could do a custom SQL query:
global $wpdb;
$query = "SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'director' ORDER BY meta_value;";
$directors = $wpdb->get_results( $query );
foreach( $directors as $director ) :
echo $director->meta_value;
endforeach;
one thing to note here though is that since you’re not querying the associated posts, you could get values that belong to unpublished posts, if that’s a concern.
Related Posts:
- How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Max length of meta_value
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- get_pages sort alphabetically by meta value
- Assign/update the custom field value for all posts
- Order by custom field date with ASC order
- How to break meta values into different items and avoid duplicates?
- WP_query : meta_key with custom rule for specific value
- How to sort category by custom field value
- trim custom field text value and show (…)
- Query post order by post and desc not working
- How to wrap meta values seperated by comma in ? [closed]
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Run a check for multiple meta key values
- Filter by custom field (meta_key) using JSON API
- Removing link ” from ” on meta_value in custom feilds
- Sort alphabetically by custom field
- pre_get_posts : only get posts by wp_usermeta value
- meta_value and meta_key filtering returning no posts [closed]
- IF Custom field value equals ZERO
- How to update a custom field in all posts with the value of another custom field in the same post?
- Update post meta custom field using block editor
- How to add custom filed value after in wp post title
- Sortable Custom Columns not sorting correct
- query_posts with meta_value
- Show array of meta_value in Edit Post Coloum
- Making WP_Query limit results by date before today where date is a meta_query
- User query – getting values for custom meta keys/fields
- get posts based on non-single metadata
- Best way to insert a list of links into a post outside of the_content
- Set class if a meta value is set within post archive
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- How to get all wp_posts in wordpress fetched from database
- Create Shortcode shows only posts with custom_field meta
- 4 Unique Random Posts based on Custom Field Values
- Custom Field: Display only if a specific key is selected outside the loop
- Insert shortcode before and after a list automatically
- How can I display only the post titles from a selected category in columns?
- Foreach giving one too many list items, how can I remove the last empty line?
- WP Query Args – search by meta_key or title
- Saving multiple custom meta box fields
- get Custom field label (select/dropdown) on front end
- ORDER BY custom field value
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- Create a select drop down of available menus
- copy attachments to another post type and change attachment url
- Cannot edit post meta fields with rest API
- Only display custom field if it there is a value inside
- Slow meta query with multi meta keys
- Custom Field Multiple Clauses
- Custom field values repeating
- Send Multiple Custom Field Values Through the URL
- $wp_query meta_key naming issue [closed]
- Meta_query and numeric comparison [closed]
- Separate table or usermeta
- Woocommerce with metabox plugin
- using multiple meta_key and meta_value in query_posts
- How Meta Data is different from Custom Fields of POST/PAGE in WordPress
- global function to apply filter to custom field
- How to add a new meta key and assign timestamp to posts
- Print custom field in Query Loop block
- Is there a simpler version of WP Media?
- Order RSS content by an advanced custom field value
- Advanced search by two criteria – sort by location and date (ascending or descending)
- Seach custom post type posts only by meta fields?
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Alter main archive, to show posts with meta as last
- Add microdata from schema.org [closed]
- Displaying multiple URLs as custom field values
- Collect user custom field in product page woocommerce
- How can I save custom meta to one global value?
- get posts where a custom field contains a text
- Displaying a custom field
- Importing WordPress Posts With Custom Meta Data As CSV Files Through PHPMyAdmin
- How can php be used to return data from custom fields in a post?
- Get meta field value of all catgories
- updating one custom meta field only
- Displaying a custom field containing a list creates unwanted markup
- Change Page Order by Custom Field (Magic Fields)
- Custom Field is getting the value of another page/post instead of the current one?
- Update some (not all) post titles with custom field values before running the Loop
- Use value from ACF to populate other fields
- Dynamically populate query source in Elementor post widget
- Setting user permissions per post
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- WooCommerce 3 get custom variation on process order [closed]
- query_posts -> get page_id from custom field
- author global display format
- Output Custom Field value to shortcode
- Update custom table on metabox POST
- display custom media folders to wordpress media popup
- Should I store arrays in custom fields or create custom tables?
- Problem saving meta data
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- WP_query returns error when used for custom widget
- Form fields based on custom fields
- woocommerce how in checkout to add my custom field check box, and when i check it hide the shipping adress and add tax 19% [closed]
- How can I attach files without using a plugin?
- Change Fields of Comments and make them searchable?