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
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
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
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/
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
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
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
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/
Hi Luoy,
Thanks, that worked just fine!
Can I offer you a beer?
Best regards,
Funs