我修改了我的WordPress的functions.php顯示分頁:如何在Wordpress分頁添加上一個/下一個類? (paginate_links)
<?php echo paginate_links(array(
'prev_text' => __('Previous Page'),
'next_text' => __('Next Page'),
'type' => 'list'
)); ?>
輸出幾乎是完美的:
<ul class="page-numbers">
<li>
<span class="page-numbers current">1</span>
</li>
<li>
<a class="page-numbers" href="https://domain.tld/page/2/">2</a>
</li>
…
<li>
<a class="page-numbers" href="https://domain.tld/page/10/">10</a>
</li>
<li>
<a class="next page-numbers" href="https://domain.tld/page/2/">Next Page</a>
</li>
</ul>
是有辦法的類添加到Prev
和Next
列表項目li
?
<li class="prev-list-item">
<a class="prev page-numbers" href="http://domain.tld/page/1/">Previous Page</a>
</li>
&
<li class="next-list-item">
<a class="next page-numbers" href="http://domain.tld/page/2/">Next Page</a>
</li>
函數[paginate_links()](https://codex.wordpress.org/Function_Reference/paginate_links)沒有爲此提供過濾器掛鉤。查看[源代碼](https://core.trac.wordpress.org/browser/tags/4.5.3/src/wp-includes/general-template.php#L0)3156行,它包裝所有鏈接'
' –