Forums › Forums › Search & Filter Pro › Display title instead of ID in Post Meta
- This topic has 5 replies, 2 voices, and was last updated 1 year, 9 months ago by Trevor.
-
Anonymous(Private) August 9, 2018 at 1:54 pm #184951
Good morning,
I create a search form for a client with several custom fields (create with pods).
These custom fields are relationship fields (from a custom post to another custom post), When I display the form I have the Id instead of the label of the field, Any suggestion how to fix it ?
In advance, thank you
Trevor(Private) August 9, 2018 at 2:46 pm #184960I am sorry, we do not support relationship fields from Pods, nor any of their advanced features. We may extend such support in V3. At this time, our plugin supports simple relationship fields only in ACF and ACF Pro. For example, the ACF Post Type Object, where it can display either ID or Title.
You can change the values manually, but this is only if you have a small number of options that are unlikely to change or be added to.
Anonymous(Private) February 4, 2023 at 4:13 pm #276739@Jermey Michel and @Trevor
Maybe this will help:
function filter_input_labels($input_object, $sfid) {
if($input_object[‘name’] == ‘_my_field_name’) {/* var_dump($input_object); */
// Fetch the options for this field
$options = $input_object[‘options’];// Loop through the options and update the label for each one
foreach($options as &$option) {
$post_id = $option->value;
$post = get_post($post_id);
$title = $post->post_title;$option->label = $title;
}// Update the options for this field
$input_object[‘options’] = $options;
}return $input_object;
}
add_filter(‘sf_input_object_pre’, ‘filter_input_labels’, 10, 2);It worked for me 🙂
-
AuthorPosts