Created
September 2, 2023 14:48
-
-
Save robwent/04df5befa1ed1353e40553f345ea1a04 to your computer and use it in GitHub Desktop.
Get child pages in ACF block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_type' => 'any', | |
'post_status' => 'publish', | |
'posts_per_page' => - 1, | |
'post_parent' => $post_id, // Available in ACF blocks by default | |
'order' => 'ASC', | |
'orderby' => 'menu_order', | |
'suppress_filters' => false, | |
); | |
$posts = get_posts( $args ); | |
if ( ! $posts ) { | |
return false; | |
} | |
global $post; | |
?> | |
<div class="some-block"> | |
<div class="row justify-content-center"> | |
<?php foreach ( $posts as $post ) : setup_postdata( $post ); ?> | |
<?php get_template_part( 'some-template' ); ?> | |
<?php endforeach; ?> | |
<?php wp_reset_postdata(); ?> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment