Skip Navigation

[Resolved] Post Reference field meta is not saving to post

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 5 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#1243960

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

#1243978

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