php - Loosing first pagination page number in URL when moving there
one text
there is problem I can't handle. I have category page(placed in archive.php) with pagination that displays posts. Pagination works and posts are displayed, but there's a little problem with the first pagination page. When I move there from any other pagination page, the number of the page in URL is just missing, as if it's not even pagination page, because when it happens the is_paged() function shows false.
Also the thing is when I hover on the first pagination page it shows that's really the first pagination page, but when I move there it's missing.
Hovering on the first pagination link:
After moving to the first pagination link:
Here's my pagination function I use for showing pagination, based on paginate_links():
function paginate_wp_query_obj_links($wp_query_obj)
{
if ($wp_query_obj->max_num_pages <= 1) return;
$big = 999999999;
$pages = paginate_links(array(
'type' => 'array',
'total' => $wp_query_obj->max_num_pages,
'current' => max(1, get_query_var('paged')),
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'prev_text' =>
'<span class="pagination__arrow pagination__arrow--position--prev" aria-hidden="true">
<svg width="8" height="12" viewBox="0 0 8 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.64341 11.6562L7.30005 5.99958L1.64342 0.342916L0.700081 1.28558L5.41472 5.99958L0.70008 10.7136L1.64341 11.6562Z" fill="black" />
</svg>
</span>',
'next_text' =>
'<span class="pagination__arrow pagination__arrow--position--next" aria-hidden="true">
<svg width="8" height="12" viewBox="0 0 8 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.64341 11.6562L7.30005 5.99958L1.64342 0.342916L0.700081 1.28558L5.41472 5.99958L0.70008 10.7136L1.64341 11.6562Z" fill="black" />
</svg>
</span>'
));
if (is_array($pages)) {
$pagination_layout = '';
$pagination_layout .= '<nav classs="pagination" aria-label="Page navigation"><ul class="pagination__list">';
foreach ($pages as $page) {
$temp = str_replace('page-numbers', 'page-link', $page);
$pagination_layout .= '<li class="pagination__el">' . $temp . '</li>';
}
$pagination_layout .= '</ul></nav>';
return $pagination_layout;
}
}
And the way I get posts:
<?
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$categoryCat = "12";
$posts_per_page = get_option('posts_per_page');
$art_objects = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => $posts_per_page,
'post_status' => 'publish',
'cat' => $categoryCat,
'paged' => $paged,
));
?>
<? if ($art_objects->have_posts()) : ?>
SHOWING POSTS
<? endif; ?>
I wanna find a way to keep the value the first pagination page when moving there, is there any way to do that?
Source