给WordPress上一篇下一篇文章自定义class

WordPress在文章页通常会有上一篇、下一篇文章的链接,如果要为链接自定义class怎么办?在WordPress主题的 functions.php 中插入:

add_filter('next_posts_link_attributes', 'posts_link_attributes_1');
add_filter('previous_posts_link_attributes', 'posts_link_attributes_2');
 
function posts_link_attributes_1() {
    return 'class="prev-post"';
}
function posts_link_attributes_2() {
    return 'class="next-post"';
}

来自:https://wpmore.cn/%e7%bb%99wordpress%e4%b8%8a%e4%b8%80%e7%af%87%e4%b8%8b%e4%b8%80%e7%af%87%e6%96%87%e7%ab%a0%e8%87%aa%e5%ae%9a%e4%b9%89class.html