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

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注