I’ve got two different loops. The default on the homepage, but a secondary loop on the archive page. It grabs all the content, like so:
<?php // WP_Query arguments
$args = array (
'posts_per_page' => '3'
);
// The Query
$archiveQuery = new WP_Query( $args );
// The Loop
if ( $archiveQuery->have_posts() ) {
while ( $archiveQuery->have_posts() ) {
$archiveQuery->the_post(); ?>
<div class="post">
<a href="<?php the_permalink() ?>">
<?php first_item(); ?> </a>
However, when I include posts_nav_link();
, it does not show up. Is this because it is a static page? I am using this for an infinite scroll.
posts_nav_link
is intended for archive pages. That function usesget_next_posts_nav_link
which uses theglobal
variable$wp_query
. There is a check for!is_singular()
. That will always be false on your “static” page, since$wp_query
will represent the page (single) and not the query you have created. So, yes, it is because it is a static page.Chip Bennett wrote/compiled an fairly exhaustive answer explaining how to make pagination work.
Make sure and include a wp_reset_postdata() at the end of a loop created with WP_Query.