Last active
September 6, 2017 17:55
-
-
Save bhubbard/6382025 to your computer and use it in GitHub Desktop.
Loop for Child Pages.
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
<!-- Display all child pages --> | |
<? | |
$child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); | |
if ( $child_pages ) : | |
foreach ( $child_pages as $pageChild ) : | |
setup_postdata( $pageChild ); | |
$thumbnail = get_the_post_thumbnail($pageChild->ID, 'thumbnail'); | |
if($thumbnail == "") continue; // Skip pages without a thumbnail | |
?> | |
<div class="child-thumb"> | |
<a href="<?= get_permalink($pageChild->ID) ?>" rel="bookmark" title="<?= $pageChild->post_title ?>"> | |
<?= $pageChild->post_title ?><br /><?= $thumbnail ?> | |
</a> | |
<div style="width:70%;float:right;"> | |
<?php the_excerpt(); ?> | |
</div> | |
</div><br /><br /> | |
<? | |
endforeach; | |
endif; | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment