Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $post;
- function showSubpages( $post_id, $current_level ) {
- $subpages = get_posts( array(
- 'post_type' =>'page',
- 'posts_per_page' =>-1,
- 'post_parent' => $post_id,
- 'order_by' => 'title',
- 'order' => 'ASC' ) );
- if ( empty($subpages) ) {
- return;
- }
- echo '<ul class="subpages level-'.$current_level.'-subpages">';
- foreach ($subpages as $page) {
- $image = get_the_post_thumbnail( $page->ID, 'thumbnail' );
- echo '<li>';
- echo '<a href="'.get_permalink($page->ID).'">';
- echo '<span>';
- echo apply_filters( 'the_title', $page->post_title );
- echo '</span>';
- echo '<div class="feature_image">' . $image . '</div>';
- echo '</a>';
- showSubpages( $page->ID, $current_level+1 );
- echo '</li>';
- }
- echo '</ul>';
- }
- showSubpages( $post->ID, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement