I wanted to use different HTML for the first post in a blog.
I did it by making 2 loops. Unfortunately this has stopped the pagination from working. I guess it is because I am creating a new query to solve the problem.
How can I solve my problem while still having a working pagination?
The original single loop code code
<?php # The Loop
if ( have_posts()): ?>
<div class="row">
<?php # Loop through
while ( have_posts() ) : the_post();
include( 'includes/snippets/'.$post->post_type.'-card.php');
endwhile; ?>
</div>
<?php else:
echo '<div class="alert alert-warning">No results found.</div>';
endif; ?>
My attempt at a double loop
<?php
$args = array(
'posts_per_page' => '1',
);
$query = new WP_query ( $args );
if ( $query->have_posts() ) { ?>
<?php while ( $query->have_posts() ) : $query->the_post(); /* start the loop */ ?>
<?php include( 'includes/snippets/'.$post->post_type.'-card-large.php'); ?>
<?php // End the loop.
endwhile;
}
$args = array(
'posts_per_page' => '11',
'offset' => '1',
);
$query = new WP_query ( $args );
if ( $query->have_posts() ) { ?>
<?php while ( $query->have_posts() ) : $query->the_post(); /* start the loop */ ?>
<?php include( 'includes/snippets/'.$post->post_type.'-card.php'); ?>
<?php // End the loop.
endwhile;
} ?>
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>