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?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.