Skip Navigation

[Resolved] wp_postmeta value for key _wpcf_belongs_address_id doesn’t match admin

This thread is resolved. Here is a description of the problem and solution.

Problem: The postmeta information for _wpcf_belongs_slug_id doesn't match the relationships I see in wp-admin.

Solution: In the new relationships system, relationships are no longer represented in the postmeta table. Use the Post Relationships API to associate posts programmatically.

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

This support ticket is created 6 years, 2 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by darryl 6 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1131105
Edit_Address_Check_‹_Opportunity_Zone_Invest_—_WordPress.jpg
phpmyadmin_wpengine_com___WP_Engine___wp_ozinvest___wp_postmeta___phpMyAdmin_4_8_3.jpg

I am trying to:

in functions.php i'm setting the value for key: _wpcf_belongs_address_id to 2778 which is the right parent id. When I do that, there's no parent / child showing in either of the child or parent posts.

When I manually link the parent / child, the parent post id shows as 2780 for some reason instead of the actual parent post id of 2778. When it's 2780, the relationship shows up on the child and parent posts.

Link to a page where the issue can be seen:
screenshots attached

I expected to see:
i expected to see in the database the parent id being 2778, but it's showing 2780. In the child post (2777), it's showing 2778.

Instead, I got:

#1131483

in functions.php i'm setting the value for key: _wpcf_belongs_address_id to 2778 which is the right parent id. When I do that, there's no parent / child showing in either of the child or parent posts.
Hi, I can see that you're using the new Relationships feature in Types. The process for programmatically relating two posts is no longer based on the _wpcf_belongs_slug_id meta key, so getting or setting that meta value is no longer recommended for new post relationships.

We have a new API, toolset_connect_posts, that should be used instead to programmatically relate two posts. We have another API, toolset_get_related_post, which can be used to get a post parent ID. I recommend you check out the documentation for these new post relationship APIs, and implement them in your code instead of trying to use _wpcf_belongs_slug_id - it's deprecated and won't work for relationships created in the new system.
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

Let me know if you have questions about these new APIs, and I'll be happy to help.

#1133156

My issue is resolved now. Thank you!