Hi @andrewtayloruk82
Yes, absolutely – https://prnt.sc/peCEr9nZaJrF but please note that after you apply your code, you need to go to the filter set and hit update. So it will refresh filter terms transitions. Perhaps that was the issue that you cannot change it.
Even thought this is out of the scope of support policy, we already spend time on it to test it, here is the code example (you can improve it as it was written for testing purposes):
add_filter('wpc_filter_post_meta_term_name', 'wpc_acf_labels_instead_of_values', 20, 2);
function wpc_acf_labels_instead_of_values($term_name, $meta_key)
{
// Specify the meta keys for which you want to modify values ('relation_test' is out created custom field in the previous example)
$meta_keys = array('relation_test', 'your_second_meta_key', 'third_meta_key');
if (in_array($meta_key, $meta_keys)) {
if (function_exists('acf_get_field')) {
$field = acf_get_field($meta_key);
if ($field) {
// Check if the field is a relationship field by its type
if ($field['type'] === 'relationship') {
// Convert term_name (which contains IDs) into array if multiple
$ids = explode(',', $term_name);
// Initialize an empty array to store the post titles
$post_titles = [];
foreach ($ids as $id) {
// Get the post object by ID
$post = get_post($id);
if ($post) {
$post_titles[] = $post->post_title;
}
}
// Join the titles into a string (if multiple)
$term_name = implode(', ', $post_titles);
}
// For other field types, continue as before
else {
if (isset($field['choices']) && !empty($field['choices'])) {
$new_choices = [];
foreach ($field['choices'] as $key => $value) {
$new_key = mb_strtolower($key);
$new_choices[$new_key] = $value;
}
$term_name_test = mb_strtolower($term_name);
if (isset($new_choices[$term_name_test])) {
$term_name = $new_choices[$term_name_test];
}
}
}
}
}
}
return $term_name;
}
Best Regards – Victor