I’m using Advanced Custom Fields with post-type. I have some select custom fields, and I want to show all the label choices from each field.
I’ve tried this way.
Here is a modified version of answer provided by @BFDatabaseAdmin matching the exact meta_value in "LIKE"
function get_acf_key($field_name) {
global $wpdb;
$length = strlen($field_name);
$sql = "
SELECT `meta_key`
FROM {$wpdb->postmeta}
WHERE `meta_key` LIKE 'field_%' AND `meta_value` LIKE '%\"name\";s:$length:\"$field_name\";%';
";
return $wpdb->get_var($sql);
}