Forums Forums Search & Filter Pro Display title instead of ID in Post Meta

Tagged: , ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #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 ?
    id instead of title

    In advance, thank you

    Trevor
    #184960

    I 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
    #184978

    Hi thanks for you answer,

    In the meantime, I have found a solution with a php function and Jquery. Maybe not the most elegant way to do it but it’s working.

    Have a nice day.

    Trevor
    #184988

    Another thought. We have a filter:

    Filter Input Object

    This allows you to change the labels. You could dynamically fetch the title from the Post ID’s and return the titles?

    Anonymous
    #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 🙂

    Trevor
    #276741

    Thanks for sharing. It shouldn’t be happening in the latest version of our plugin (2.5.13).

Viewing 6 posts - 1 through 6 (of 6 total)