Last active
December 17, 2015 00:19
-
-
Save achudars/5520450 to your computer and use it in GitHub Desktop.
Create a list of child pages and display their content on the parent page including the featured image using PHP
This file contains hidden or 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 | |
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); | |
?> | |
<?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?> | |
<div class="child-thumb"> | |
<?php echo get_the_post_thumbnail($pageChild->ID, 'thumbnail'); ?> | |
<a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?></a> | |
</div> | |
<?php endforeach; endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment