• Resolved jjci

    (@jjci)


    I am having a problem in PHP retrieving the values of parent PODS fields in a bi-directional parent-child relationship. I can retrieve values for WP fields, but not PODS fields.

    I have three Custom Post Types; User (extended), Locations, and User-Locations.
    The User-Locations CPT is a link-table, and each entry has one parent User and one parent Location, and these are the bi-directional relationships.

    As a debug test, I used a PODS template on the User-Locations CPT, and the PODS fields that I require are available and display properly.

    In my PHP code, I do the following steps after retrieving the User-Locations entry:

    $parent_Location = $pods_User_Locations->field(‘parent_location’);
    $parent_ID = $parent_Location[‘ID’];
    $parent_title = $parent_Location[‘post_title’];
    $parent_telephone = $parent_Location[‘telephone’];

    The retrieval of the ‘ID’ and the ‘post_title'(which are WP fields) work just fine. However, the retrieval of ‘telephone’ (which is a PODS field) returns NULL. I did a var_dump of the ‘$parent_Location’ array, and it appears that the ‘telephone’ values are not there. I performed the same test with a different PODS field and received the same results. So, I concluded that standard WP fields can be retrieved, but PODS fields cannot.

    I have tried variations such as ‘telephone.meta_value’, but that didn’t work, either.

    Is there a setting at the PODS CPT relationship field level which determines how much information is included in the ‘parent_Location’ field/array? If so, where is this set?

    I’ve tried everything I can think of, but I am stumped.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jjci

    Only the WP_Post fields are part of the array. Any other fields need to be fetched using the field or display methods.
    Example:

    
    $parent_Location = $pods_User_Locations->field('parent_location');
    $parent_ID = $parent_Location['ID'];
    $parent_pod = pods( 'location', $parent_ID );
    $parent_telephone = $parent_pod->display( 'telephone' );
    

    Cheers, Jory

    Thread Starter jjci

    (@jjci)

    Understood.

    Thanks, Jory.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with retrieving ‘parent’ PODS field values’ is closed to new replies.