Child Pages Loop
If anyone can help that'd be great.
I've found a snippet of code that I've used which is pretty much doing what I want it to do, which lists out subpages of the parent, adds a thumbnail if there is one, and added a custom excerpt.
However, the problem is that I can't add individual ?php post_class(); ?
to a div inside the loop, its using the class from the parent and repeating for the subpages.
?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 ); ?
?php
// Must be inside a loop.
if ( has_post_thumbnail($pageChild-ID) ) {
get_the_post_thumbnail('page-thumb-mine');
}
// else {
// echo 'img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/icon-cropped.png" /';
// }
?
div ?php post_class(); ?
?php echo get_the_post_thumbnail($pageChild-ID, 'page-thumb-mine'); ?
h3a href="?php echo get_permalink($pageChild-ID); ?" rel="bookmark" title="?php echo $pageChild-post_title; ?"?php echo $pageChild-post_title; ?/a/h3
?php echo excerpt(28); ?
/div
/div
?php endforeach; endif;
?
Any help would be appreciated!
Thanks
Andy
Topic loop child-pages post-class pages Wordpress
Category Web