Skip Navigation

[Resolved] Get parent in a relationship not working as expected

This support ticket is created 5 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.

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)

This topic contains 2 replies, has 2 voices.

Last updated by cedricd-2 5 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#1168864

Tell us what you are trying to do?
I'm trying to get the language of a traduction and et an empty array.

I have terms (terme), languages (langue) and an intermediary post Translation (traduction).

When in a loop of traduction, I want to access the language info of the post.

$language = toolset_get_related_posts(get_the_ID(),array('traduction','langue'),'parent');
print_r($language);

It outpost an empty array and I wanted to have the ID of the given language.

Is there any documentation that you are following?
API Post relationship

What is the link to your site?
Staging

Thanks

#1169512

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi there,

Thank you for contacting us and I'll be happy to assist.

Can you please update your code as follows and see if it works:


	$query_by_element = get_the_ID(); // ID of post to get relationship from
	$relationship = 'traduction'; // relationship slug
	$query_by_role_name = 'intermediary'; // $query_by_element is a intermediary in this relation 
	$limit = 100; // defaults
	$offset = 0; // defaults
	$args = array(); //nothing needed
	$return = 'post_id'; // We want Post ID
	$role_name_to_return = 'parent'; // We want parent. Change it to 'child' to get child relative

	$get_results = toolset_get_related_posts(
					$query_by_element,
					$relationship,
					$query_by_role_name,
					$limit,
					$offset,
					$args,
					$return,
					$role_name_to_return
					);
	
	print_r($get_results);

Feel free to adjust the values as need and make sure that relationship slug is "traduction".

I hope this helps and please let me know how it goes.

regards,
Waqar

#1169677

My issue is resolved now. Thank you!

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