I’m attempting so as to add pagination for my Archive. I need to present 12 posts per web page after which present the ‘subsequent’ / ‘earlier’ buttons.
Once I manually change the worth of the $paged variable, the 1 right into a 2 it really works.
Once I click on the Subsequent button on the archive web page, it masses a really bizarre theme web page. The url appears to be like like: ‘/web page/2/’.
What am I doing incorrect?
That is the code I wrote up to now:
<?php
international $paged,$wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'realisaties',
'posts_per_page' => 12,
'paged' => $paged,
'order' => 'ASC'
);
$archive_query = new WP_Query($args);
whereas ($archive_query->have_posts()) : $archive_query->the_post();
$picture = get_field('preview_afbeelding');
if( !empty($picture) ):
$url = $picture['url'];
$title = $picture['title'];
$alt = $picture['alt'];
$caption = $picture['caption'];
// thumbnail
$dimension = 'medium';
$thumb = $picture['sizes'][ $size ];
$width = $picture['sizes'][ $size . '-width' ];
$top = $picture['sizes'][ $size . '-height' ];
if( $caption ): ?>
<div class="wp-caption">
<?php endif; ?>
<div class="col-md-3">
<?php echo get_the_title(); ?>
<a href="<?php the_permalink() ?>" title="<?php echo $title; ?>">
<img class="realisatie-img img-responsive" src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" title="" width="<?php echo $width; ?>" top="<?php echo $top; ?>" />
<br />
</a>
</div>
<?php if( $caption ): ?>
<h2> <?php echo get_the_title(); ?></h2>
<p class="wp-caption-text"><?php echo $caption; ?></p>
</div>
<?php
endif;
endif;
endwhile;
?>
<?php next_posts_link('Older Entries »', $archive_query->max_num_pages); ?>
<?php previous_posts_link('Newer Entries', $archive_query->max_num_pages); ?>
<?php wp_reset_query(); ?>
</div>
</div>