Skip Navigation

[Resolved] Assigning post to parent with PHP

This support ticket is created 7 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Minesh 7 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#470491

I am trying to: use PHP to assign a child to a parent using:

add_post_meta($post_id, '_wpcf_belongs_' . $listingtype . '_id', $parent_post);

I expected to see: The child Post Relationship show the parent post and; the parent Post Relationship show the child post.

Instead, I got: Only the child post is showing the relationship with the parent. The parent doesn't show the child post in the Post Relationship.

Is there something else that I need to do?

Thanks Chris

#470658
Screen Shot 2016-12-24 at 8.28.04 am.png
Screen Shot 2016-12-24 at 8.28.41 am.png

just a little further info from me on this one.

If I run a var_dump on the types_child_posts it seems that the parent post has the posts added:

$child_listings = get_post_meta($this_post, 'types_child_posts');
var_dump ($child_listings);

First screenshot shows the dump ( note there are multiple arrays created from having run this a number of times whilst testing ).

Second screenshot shows the Post Relations section of the parent post in the WP backend. Note that the child posts are not showing here.

#470960

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I tried to reproduce this issue but unfortunately I do not able to reproduce this issue.

1)
Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes?

2)
Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

3)
Could you please activate WP_DEBUG from wp-config.php file and send me possible errors for review.

4)
Are you using any cache plugin? if yes, Could you please try to delete the cache and try to resolve your issue.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.