Skip Navigation

[Resolved] update code for Toolset Types 3.

This support ticket is created 5 years, 7 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 1 reply, has 2 voices.

Last updated by Christian Cox 5 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#1252877

Tell us what you are trying to do?
convert a plugin from Types 2 to Types 3
In code there is a line like this:
if (get_post_meta($post->ID, "_wpcf_belongs_floor_id", true)){
Can you help me to convert this. I´m trying to learn more php and is playing with a plugin that i like to convert to Types 3. There is more code to convert but I think this line could help me get further! 🙂

Is there any documentation that you are following?
How to Migrate Your Site to New Post Relationships

Is there a similar example that we can see?
Not really
What is the link to your site?
local

#1253145
if (get_post_meta($post->ID, "_wpcf_belongs_floor_id", true)){

It looks like this code is set up to test whether the current post has a parent "Floor" post. In the new post relationships system, you should use the post relationships API to test whether or not a post has a parent. The post relationships API information is all here: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api

You could do something similar in the new system like this:

$floor = toolset_get_parent_post_by_type( $post->ID, 'floor' );
if ($floor ) {