0

我需要将过滤器添加到特定的 wordpress 函数,该函数在可插入函数主题的函数 f 包含的文件中定义

函数.php:

if (!function_exists('nectar_colors_css_output')) {
    function nectar_colors_css_output(){
        include('css/colors.php');
    }
}

颜色.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');

我怎样才能让这个过滤器工作?

4

1 回答 1

0

你到底想过滤什么?您可能误解了这些概念。

以您提供的示例为例。父级在创建函数之前检查函数是否存在。所以基本上,如果你在你孩子的主题中定义它,父母会知道它在那里并且不会创建一个默认主题。

#themename-child

function nectar_colors_css_output(){
    error_log("It worked!");
}
于 2015-01-14T11:41:10.907 回答