admin管理员组文章数量:1122796
I wrote this code:
<div class="col-12">
<div class="pagination d-flex justify-content-center mt-5">
<!-- <a href="#" class="rounded">«</a>
<a href="#" class="active rounded">1</a>
<a href="#" class="rounded">2</a>
<a href="#" class="rounded">3</a>
<a href="#" class="rounded">4</a>
<a href="#" class="rounded">5</a>
<a href="#" class="rounded">6</a>
<a href="#" class="rounded">»</a> -->
<?php
$total_pages = $loop->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
$base_url = get_pagenum_link(1);
$paged_url = add_query_arg('paged', '%#%', $base_url); // Replace %%% with actual page number
echo paginate_links(array(
'base' => $paged_url,
'format' => '%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
}
wp_reset_postdata();
?>
</div>
</div>
In this code, the commented out part is actually how the active page number inside pagination should look like, but I am having no ideas on how I can manage this issue.
I wrote this code:
<div class="col-12">
<div class="pagination d-flex justify-content-center mt-5">
<!-- <a href="#" class="rounded">«</a>
<a href="#" class="active rounded">1</a>
<a href="#" class="rounded">2</a>
<a href="#" class="rounded">3</a>
<a href="#" class="rounded">4</a>
<a href="#" class="rounded">5</a>
<a href="#" class="rounded">6</a>
<a href="#" class="rounded">»</a> -->
<?php
$total_pages = $loop->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
$base_url = get_pagenum_link(1);
$paged_url = add_query_arg('paged', '%#%', $base_url); // Replace %%% with actual page number
echo paginate_links(array(
'base' => $paged_url,
'format' => '%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
}
wp_reset_postdata();
?>
</div>
</div>
In this code, the commented out part is actually how the active page number inside pagination should look like, but I am having no ideas on how I can manage this issue.
Share Improve this question edited May 17, 2024 at 9:32 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked May 17, 2024 at 7:23 user242793user242793 11 Answer
Reset to default 1By default paginate_links()
gives you several ways to target the current page:
- It will replace the
a
element with aspan
element, because there's no point in a page linking to itself - It adds the class
current
to thespan
- It adds the
aria-current
attribute to thespan
Any one of these can be used to apply whatever styling you want
本文标签: cssHow can I highlight the active page using paginatelinks()
版权声明:本文标题:css - How can I highlight the active page using paginate_links()? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306890a1933119.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论