Skip Navigation

[Gelöst] get all the varies post type children post of a parent based on parent id

This support ticket is created vor 2 Jahre, 8 Monate. 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 5 Antworten, has 2 Stimmen.

Last updated by davidZ-4 vor 2 Jahre, 8 Monate.

Assisted by: Minesh.


Tell us what you are trying to do? get a list of all the children post of a parent. the children are various custom type posts

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
hidden link

a 'Plan" have multiple children from a few CPT's
e.g. a plan is a parent of budget, net worth and other custom post types

as far as I understand the current toolset_get_related_posts require a relationship to be declared. i understand that only one relationship can be called out.

is there a way to get all the children of the parent across multiple relationships
i.e plan_budget and plan_net and plan_target etc..




Languages: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Using toolset_get_related_posts() post relationship API function you can only get the one relationship posts.

You should check the example given with the following link using the WP_Query where you can define multiple relaitonship:

Please note that with 'relationship' you will require to use your relationship slug for example 'plan_budget ' instead of array.


Hi Minesh,
Thanks for the quick response.
I still need some help.

I have the following code:

	//parent post id	
	$pid = '123456';
	// get an child posts of parent
			$query = new WP_Query( 
					'post_type' => 'plan',
					'posts_per_page' => -1,
					'toolset_relationships' => array(
							'role' => 'child',
							'related_to' => $pid,
							'relationship' => 'plan-v2-assumption'
							'role' => 'child',
							'related_to' => $pid,
							'relationship' => 'plan-v2-budget'

	//display the child post array - delete in final function
	echo $string;

The code return no results
what am I missing?



Languages: Englisch (English )

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

The query should return the result object.

If you can share admin access details and tell me where you added the code I'm happy to review it.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.



Languages: Englisch (English )

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

I checked and I found that you are using the one-to-one post relationship.

So, rather making things complicated, you can use the Toolset post relationship API function: toolset_get_related_post() to get the related child post for every relationship you have.

For example:

$related_assumption = toolset_get_related_post( $pid,'plan-v2-assumption','child');
$related_budget = toolset_get_related_post( $pid,'plan-v2-budget','child');

The variable $related_assumption and $related_budget will hold the child post ID. You should get the post based on the found ID and display the content as required.

The different relationship example will work when you have two different parents assigned to same child post type:
[ Consider post type B and C set as parent to post type A (child) and you want to find all A (child) post type posts belongs to different parent B and C.]

In your case its different. You have assumption and budget set as child. That is why we will have to use toolset_get_related_post() or toolset_get_related_posts().


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.