Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 添加wordpress筛选器错误_Php_Wordpress - Fatal编程技术网

Php 添加wordpress筛选器错误

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

我在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中的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"';
}
?>