• Resolved pixelshrink

    (@pixelshrink)


    Hi, I’ve got the first bit of code from https://docs.pods.io/tutorials/get-values-from-a-relationship-field/ working fine to display a File / Image / Video field in a custom post type.

    However, when I try the same with an extended post type which has a File / Image / Video field added, I get ‘Warning: Illegal string offset ‘ID” in line 12, and it displays a lot of unwanted fields. Is there a way of getting this working in the same way as a normal custom post type?

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

    (@keraweb)

    Hi @pixelshrink

    Pods field should always return the same format.
    Are you sure this field isn’t empty? And if not, what is it returning? You can check usign print_r() for example.

    Cheers, Jory

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Can you clarify whether this is a single file or multiple file field?

    Thread Starter pixelshrink

    (@pixelshrink)

    Thanks very much, it’s multiple.

    Here’s a comparison of the var_dump($related) for the CPT that does work, and the extended post type where the code mentioned above doesn’t show the download field:

    var_dump( $related )

    Pods CPT where documents are displayed:

    array(1) { [0]=> array(24) { ["ID"]=> string(3) "293" ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2021-07-29 08:23:23" ["post_date_gmt"]=> string(19) "2021-07-29 08:23:23" ["post_content"]=> string(0) "" ["post_title"]=> string(67) "Meeting name" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "inherit" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(63) "Download title" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2021-07-29 10:17:26" ["post_modified_gmt"]=> string(19) "2021-07-29 10:17:26" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> string(3) "257" ["guid"]=> string(136) "download.doc" ["menu_order"]=> string(1) "0" ["post_type"]=> string(10) "attachment" ["post_mime_type"]=> string(71) "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ["comment_count"]=> string(1) "0" ["pod_item_id"]=> string(3) "293" } } 293
    
    PODS extended post type where Illegal string offset 'ID' in $id = $rel[ 'ID' ];:
    array(24) { ["ID"]=> string(3) "392" ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2021-08-06 15:00:53" ["post_date_gmt"]=> string(19) "2021-08-06 15:00:53" ["post_content"]=> string(0) "" ["post_title"]=> string(37) "Event name" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "inherit" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(39) "Download title" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2021-09-15 15:48:54" ["post_modified_gmt"]=> string(19) "2021-09-15 15:48:54" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> string(3) "390" ["guid"]=> string(109) "download.pdf" ["menu_order"]=> string(1) "0" ["post_type"]=> string(10) "attachment" ["post_mime_type"]=> string(15) "application/pdf" ["comment_count"]=> string(1) "0" ["pod_item_id"]=> string(3) "392" }
    • This reply was modified 3 years, 2 months ago by pixelshrink.
    • This reply was modified 3 years, 2 months ago by Yui. Reason: formatting
    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Thanks for your patience here, I just really want to confirm that both fields are set as file fields and both fields are set to multiple files, not single, and not set to limit 1.

    Can you confirm?

    Thread Starter pixelshrink

    (@pixelshrink)

    Thanks for your help Scott, the one that wasn’t working was indeed set to single files, now it’s set to multiple it works. Thanks very much for your help. Glad it was a simple one!

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Great news! Glad it was easy, that’s why I wanted to double check because it seemed like it could just be that.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Get values from a relationship field in an extended post type’ is closed to new replies.