php - Wordpress List Pages and their Post Thumbnails -
needing on listing pages have in wordpress , 1st depth child sub pages, post thumbnails (or featured image). also, want exclude specific pages being listed
i looked @ wp_list_pages(); see no way of including post thumbnails
edit: andy, can't find appropriate example of how use code so. sorry, green php , using wordpress.
i think looking for:
$pages = array(); $exclude = '1,2,3'; // page id of pages want exclude $args = array( 'exclude' => $exclude, 'parent' => 0, 'post_type' => 'page', 'post_status' => 'publish' ); $parents = get_pages( $args ); foreach( $parents $parent ) { $parent -> thumbnail = get_the_post_thumbnail( $parent -> id, 'thumbnail'); $args = array( 'exclude' => $exclude, 'child_of' => $parent -> id, 'number' => 1, 'post_type' => 'page', 'post_status' => 'publish' ); $child = get_pages( $args ); $pages[] = $parent; if( count( $child ) ) { $child[0] -> thumbnail = get_the_post_thumbnail( $child[0] -> id, 'thumbnail'); $pages[] = $child[0]; } } print_r( $pages );
Comments
Post a Comment