我有一个简单的函数(在我的主题中的functions.php中),它将类添加到导航链接
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');
function posts_link_attributes() {
if (is_home() || is_front_page()) {
if (current_filter() == 'previous_posts_link_attributes') {
return 'class="prevlink ajax"';
}
elseif (current_filter() == 'next_posts_link_attributes') {
return 'class="nextlink ajax"';
}
}
}我需要这只在我的主页上工作,但它不工作。有人能帮我吗?
发布于 2016-04-23 04:54:41
我解决了向index.php添加过滤器的问题
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');我不知道这是否正确,但它工作正常。会造成什么问题吗?
https://stackoverflow.com/questions/36767268
复制相似问题