Skip Navigation

[Resolved] Parent – child relation view

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by funsE-2 9 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#279709

I am trying to: show project thumbs of a portfolio-item. The parent is "Client" and I want to show all the projects for this client

The website I'm working on: for example portfolio-item: hidden link

The site is pw-protected. Of course I can give you the passwords to login to the site...

If I can do this with Views, could you tell me how to do so?

Thanks.

Best regards,
Funs Erens | Illuster

#280090

Are you going to display the child projects "posts" of current "Client" post?
Here is a document about "Querying and Displaying Child Posts":
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

Hope it help

#280126

Hi Luoy,

Thanks for the reply. Question: do I need 'Views'-plugin to use the PHP function [types_child_posts]?

Best regards,
Funs Erens | Illuster

#280450

If you do not have a copy of Views plugin, you can try use Types function types_child_posts to query the child posts, see the section "Displaying child posts using Types PHP functions" of above document:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

#280671

Hi,

I'm sorry, but it's still not working.

Maybe I should explain my problem better.

I am displaying a portfolio-item (custom post type "portfolio") which is a child of custom post type "Client".

On this single-post item I want to display all the portfolio items related to the Parent (cpt 'client') of this post.

Is this clear?

Thanks.

Funs Erens | Illuster

#280810

Types is using a custom field "_wpcf_belongs_[parent-slug]_id" to store the parent post ID,
For example, if your custom post type "Client" is using slug "client", the meta key is "_wpcf_belongs_client_id", you can get the parent post ID, like this:

$client_id = get_post_meta(get_the_ID(), '_wpcf_belongs_client_id', true);

Withe the $client_id, you can get what you want, for example post links:

echo get_permalink($client_id );

More help:
get_post_meta
http://codex.wordpress.org/Function_Reference/get_post_meta

#281620

Hi Luoy,
I got the client_id. That worked. But know I'm trying for some time now to show the children of the parent with this id.

$klant_id = get_post_meta(get_the_ID(), '_wpcf_belongs_klant_id', true);
** here should be the children's thumbnails and title ***

Could help me out here?

Thanks.

Funs Erens | Illuster

#281882

You can try Types function to get all children posts, for example, your child post type is using slug "portfolio-item", you can try this:

$klant_id = get_post_meta(get_the_ID(), '_wpcf_belongs_klant_id', true);
$child_posts = types_child_posts('portfolio-item', array('post_id' => $klant_id));
foreach ($child_posts as $child_post) {
  echo $child_post->post_title;
  echo $child_post->fields['description'];
}

More help:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

#281894

Hi Luoy,

Thanks, that worked just fine!

Can I offer you a beer?

Best regards,
Funs

The forum ‘Types Community Support’ is closed to new topics and replies.

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