when saving a post that contains custom fields of type post reference. These fields are no longer saved. We created some documents in the past which contained post references to a WOO product and other customer post types. When saving the post_meta would then contain the field and the value would be the id of the referred post. Yesterday however we noticed that for new posts these meta fields are no longer created. When opening the post it still shows the selected post. However the meta is not being saved. The posts we created earlier (months ago) still have the meta fields. Can you please explain what could cause this?
Link to a page where the issue can be seen:
It is not public available. One of the posts where we use this is: 'transfer'. One of the post reference fields is: 'transfer-product-reference'.
Hello. Thank you for contacting the Toolset support.
First of all - After checking to debug information you shared with us, I found that you are using outdated WordPress version. Can you please update WordPress to the current version?
=> https://wordpress.org/download/
In addition to that, can you please share problem URL where I can see the fields are not saved correctly and what fields I need to look at it?
I have set the next reply to private which means only you and I have access to it.
Well - the access details you shared with me is not working at this end.
Can you please send me working access details.
In addition to this, we do not recommend to debug the issue on live site. Is it possible for you to create a test site which should be 1:1 clone of your production site and send me access details?
I have set the next reply to private which means only you and I have access to it.
Thank you for sharing working access details. I checked the link you shared with me.
I checked this post and changed the "Product" field value (post reference field) and I see its successfully changed. Am I missing anything here?
=> hidden link
Yes you are missing the fact that we cannot get the reference back in a get_post_meta call (https://developer.wordpress.org/reference/functions/get_post_meta/) as stated in the first post. When you create a new post and check the database the value isn't stored either in the postmeta table (check screenshot).
I created a test document a few minutes ago with id: 11834, as you can see in the screenshot the value isn't stored.
I understand. This looks like our Devs may have changed how post reference field is stored internally.
You need to change the get_post_meta with the Types post-relationship API function. Can you tell me where exactly you are using the get_post_meta() function?