The front page needs to have the first six posts in a carousel and then the next eight in a grid. What's the best practice for looping through that kind of design? I'm currently using "get_posts" to call the first 14 posts, and then manually calling each one after that, but I figured there has to be a better way.
Here's what I do at the beginning of index.php:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$offset = ($paged - 1) * 14;
$args = array(
'numberposts' => 14,
'offset' => $offset,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => true
);
$front_page_posts = get_posts( $args );
The problem is that I can't call "get_template_part" because there isn't actually a post loop, so the rest of my code looks something like this:
<div class="carousel">
<?php get_carousel_slide($front_page_posts[0]->ID, true); ?>
<?php get_carousel_slide($front_page_posts[1]->ID); ?>
<?php get_carousel_slide($front_page_posts[2]->ID); ?>
<?php get_carousel_slide($front_page_posts[3]->ID); ?>
<?php get_carousel_slide($front_page_posts[4]->ID); ?>
<?php get_carousel_slide($front_page_posts[5]->ID); ?>
</div>
[...]
<div class="grid">
<?php
$count = 6;
while($count < 14){
get_front_eighth($front_page_posts[$count]->ID);
$count++;
}
?>
As you can see, I have to call a separate function to get the template instead of using "get_template_part".
So what's best practice for doing this?