I am struggling to get all child posts of a parent post. I am using a custom post type.
Currently, I have used Layout Builder to create page templates and the idea is to loop through the child post of the parent post.
I am struggling to get all child posts of a parent post. I am using a custom post type.
Currently, I have used Layout Builder to create page templates and the idea is to loop through the child post of the parent post.
Hello @pavlito,
Thanks for writing to us.
In order to help you with your concern, we need to check your settings, please send your details in a secure note. Please provide the following details
You can find the Secure Note button at the bottom of your posts
Thanks
Added secure note
Hi @pavlito,
There is a Looper Provider type called Current Page Children, please try using that provider first.
Hope it helps,
Cheers!
I maybe solve the issue by adding a filter in functions.php
add_filter('cs_looper_custom_childpage', function($result, $args)
{
$page_args = array(
'post_type' => 'chapter',
'posts_per_page' => -1,
'post_parent' => get_the_ID(),
);
$cp =new WP_Query($page_args);
$child_pages=$cp->posts;
return $child_pages;
}, 10, 2);
And then using a hook provider in the layout builder
Is this a good solution?
Hi @pavlito,
Yes, you can use the solution while using the Custom option of the Looper Provider, please follow the way explained in the following thread.
Thanks
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.