• Resolved junkes

    (@junkes)


    When I’m adding a song to my CD CPT, sometimes I get confused because I have more than one track with the same name (same post_title). Is there a easy way to add more than one field to Selection List? And, more than that, can it be a relationship field? So, it would show something like “{@post_title} | {@custom.relationship.field}” of the object.

Viewing 1 replies (of 1 total)
  • Plugin Support Paul Clark

    (@pdclark)

    See https://docs.pods.io/code-snippets/multiple-fields-pick-list/

    <?php
    add_filter(
    'pods_field_pick_data',
    function ( $data, $name, $value, $options, $pod, $id ) {

    $pod_name = 'cd';
    $first_field = 'post_title';
    $second_field = 'relationship_field_name.subfield_name';

    if ( $name === 'pods_field_' . $pod_name ) {
    foreach ( $data as $dataid => &$value ) {
    if( $dataid ){
    $p = pods( $pod_name, $dataid );
    $value = sprintf(
    '%s - %s',
    $p->display( $first_field ),
    $p->display( $second_field )
    );
    }
    }
    }
    return $data;
    },
    1,
    6
    );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.