I have CPT called post-author
that have 'has_archive' => true
.
In single-post-author.php
I want to display author info with custom fields, and then show all of his posts with pagination.
Code below works and display posts and number on pages, but when I go to the next page its 404 or redirects me to the same page. Also this code works in archive.php
.
If I put this code to single.php it lists posts with pagination numbers, but when I want to go to the next page it redirects me to page 0, even if i typu manually /page/2.
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 4,
'paged' => $our_current_page
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post();
?>
<h4><?php the_title(); ?></h4>
<?php
}
}
echo paginate_links(array(
'total' => $post_query->max_num_pages
));
?>