Php 添加wordpress筛选器错误
我在function.php文件中声明此过滤器:Php 添加wordpress筛选器错误,php,wordpress,Php,Wordpress,我在function.php文件中声明此过滤器: <?php add_filter('next_posts_link_attributes', 'posts_link_attributes'); function posts_link_attributes() { return 'class="styled-button"'; } ?> 但是把这个拿回来: 致命错误:无法重新声明posts\u link\u attributes() 在index.php中的funct
<?php
add_filter('next_posts_link_attributes', 'posts_link_attributes');
function posts_link_attributes() {
return 'class="styled-button"';
}
?>
但是把这个拿回来:
致命错误:无法重新声明posts\u link\u attributes()
在index.php中的functions.php中声明)
因为我在index.php中使用了next_post_link()
有解决办法吗?这不起作用的原因是什么
谢谢你们的帮助,伙计们 使回调更具体
<?php
add_filter('next_posts_link_attributes', 'posts_link_attributes_style_button');
function posts_link_attributes_style_button() {
return 'class="styled-button"';
}
?>
将函数名更改为其他名称:
<?php
add_filter('next_posts_link_attributes', 'my_posts_link_attributes');
function my_posts_link_attributes() {
return 'class="styled-button"';
}
?>
太棒了,谢谢你的帮助!我不知道它已经被“使用”了。@SnippetSpace没问题。刚刚添加了如何检查函数是否存在。刚刚添加了!不得不等待时限
<?php
add_filter('next_posts_link_attributes', 'my_posts_link_attributes');
function my_posts_link_attributes() {
return 'class="styled-button"';
}
?>