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"'; }