I'm currently trying to fetch all my pages from different post types and display them on a single page with a WP Query but I wanted to display them in such a template in the HTML instead of it all coming as a big list of course I'm not entirely sure if this is even possible
Parent
Child
Parent
Child
Parent
Parent
Parent
This is what I'm using so far
$args = array(
'post_type'=> 'page',
'orderby' => 'title',
'post_status' => 'publish',
'order' => 'ASC',
'posts_per_page' => 20,
);
$result = new WP_Query($args);
?>
<section>
<h2><?php echo $post_type; ?></h2>
<?php
while ($result->have_posts()) {
$result->the_post();
$post = get_post();
?>
<ul>
<li class="">
<a href=""><?php echo the_title(); ?></a>
</li>
</ul>
<?php
}
wp_reset_postdata();
?>
</section>
<?php }
I tried using wp_list_pages but I'm not sure how to use that for different post types and also I would like to have limited posts per page not display everything