Mayccoll
2/11/2016 - 7:41 PM

Get Children Pages

Get Children Pages

<?php
    // Set up the objects needed
    $my_wp_query = new WP_Query();
    $all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => -1));
    // Get the page as an Object
    $parent_page =  get_page_by_title(get_the_title());
    // Filter through all pages and find Portfolio's children
    $children_page = get_page_children( $parent_page->ID, $all_wp_pages );

    foreach ( $children_page as $key ) {
        ?>
        <div class="col-xs-12 col-sm-4">
            <a href="<?php echo get_permalink( $key ) ?>">
                <header>
                    <?php echo get_the_title( $key ) ?>
                </header>
                <div class="">
                    <?php echo get_the_post_thumbnail( $key ); ?>
                </div>
            </a>
        </div>
        <?php
    }
?>