我需要为特定的wordpress函数添加一个过滤器,该函数在一个可插入函数主题函数f
包含的文件中定义。的functions.php:
if (!function_exists('nectar_colors_css_output')) {
function nectar_colors_css_output(){
include('css/colors.php');
}
}
colors.php:
<?php
function nectar_colors() {
// not relevant what happens here, but I have
// to call another function before this one is called!
}
?>
我使用子主题,当我尝试从子主题的functions.php中过滤此函数时,没有任何反应。这是因为在从子主题调用过滤器之后,父主题的可插入函数将被称为。
我在子主题的functions.php中的过滤函数是
function filter_function() {
// some custom actions...
}
add_filter('nectar_colors', 'filter_function');
如何让此过滤器正常工作?
答案 0 :(得分:0)
您到底想要过滤的是什么?你可能误解了这些概念。
提供你的例子。父项在创建函数之前检查函数是否存在。 所以基本上,如果你在孩子的主题中定义它,那么父母就会知道它并且不会创建一个默认的主题。
#themename-child
function nectar_colors_css_output(){
error_log("It worked!");
}