List child pages and featured image
-
I’m using this string of code to fetch a custom post type (Sample), as well as it’s featured image:
<?php global $post; $args = array( 'post_type' =>'sample', 'numberposts' => -1, 'orderby' => 'date', 'order' => 'ASC' ); $sample_posts = get_posts($args); ?> <?php if($sample_posts) { ?> <?php $i=0; //start post count at "0" foreach($sample_posts as $post) : setup_postdata($post); $i++; //add 1 to the total count ?> <div class="portfolio-box <?php if($i===4){ echo 'remove-margin'; } ?>"> <?php if ( has_post_thumbnail() ) { ?> <a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>" class="opacity"><?php the_post_thumbnail('portfolio'); ?></a> <a href="<?php the_permalink(' ') ?>"><?php the_title(); ?></a> <?php } ?> </div> <!-- END home-approval-box --> <?php //reset the count to "0" and clear the divs if($i===4){ echo '<div class="clear"></div>'; $i=0; } ?> <?php endforeach; ?> <?php } wp_reset_postdata(); ?>
I would now like to re-use that string, but for certain child pages. What would I need to adjust to make it work?
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘List child pages and featured image’ is closed to new replies.