I am trying to:
retrieve a meta field with
get_post_meta( 29391, 'wpcf-package', true );
Link to a page where the issue can be seen:
hidden link
you can access the test page template in the "new" theme its test.php
figured id make it easy for you guys to troubleshoot
heres a direct link to the post thats not saving the "package" field meta
hidden link
I expected to see:
the post id that was saved in the post reference field
Instead, I got:
emptiness in my soul
even when i run var_dump(get_post_meta( 29391));
i dont see the metafield even listed in the dump.....but whenever i navigate to the post in the admin area the value is there and saved
very weird
Hi Michael,
Thank you for contacting us and I'll be happy to assist.
The "Post Reference" type fields are special fields in which information is stored in the form of post relationships:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/using-post-reference-fields-to-display-information-from-a-related-post/
This is the reason, you're not able to access its data using the WordPress' default function like "get_post_meta".
To get the saved post's ID from a post reference type field, you can use the "types_render_field" function from the "Types Fields API".
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/ )
Example:
types_render_field( 'package', array( 'item' => 29391 ) );
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar