Custom loop pagination links not working

I’m bringing up an issue that could not be solved after googling for solutions over a few days. The goal I have to meet is to output a pagination for a custom post type named office-magazines with working links. I already managed to output the pagination but clicking any of the links within it takes me to the top page.

Here’s the code I embedded into the page template:

<?php
global $wp_query, $paged;
$paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1;

$args = array(
‘post_type’ => ‘office-magazines’,
‘posts_per_page’ => 9,
‘paged’ => $paged,
‘has_archieve’ => true
);

$catquery = new WP_Query($args);
?>

<p class=”pagination”>
<?php echo custom_pagination_bar( $loop ); ?>
</p>

Passing ‘post_type’ => ‘office-magazines’ is meant to filter out all posts apart from the ones belonging to the custom post type, ‘office-magazines’.

Using the next code in functions.php, I intended to define the function of the pagination:

function custom_pagination_bar($custom_loop) {
$big = 999999999;
echo paginate_links( array(
‘base’ => str_replace( $big, ‘%#%’, get_pagenum_link( $big ) ),
‘format’ => ‘?paged=%#%’,
‘current’ => max( 1, get_query_var(‘paged’) ),
‘total’ => $custom_loop->max_num_pages
) );
}

The same code works for the main post pagination which is output in a separate template page but fails for the custom post pagination.

Could someone please help me find a solution to getting the custom post pagination links to work?

Hoping for some advice,

Ead

Read more here:: Custom loop pagination links not working

Leave a Reply

Your email address will not be published. Required fields are marked *