【发布时间】:2015-01-30 12:45:10
【问题描述】:
在我的子主题中,我想在没有 if (!function_exists(...)) 语句的情况下覆盖父级的函数。
我找到了一个似乎可行的解决方案。在我的孩子主题中,我写了以下内容:
if (function_exists('parent_function')){
override_function('parent_function', '$param1', '$param2', 'child_function($param1, $param2);');
}
function child_function($param1, $param2){
// some code
}
我对 wordpress 比较陌生,尽管代码可以满足我的要求,但我怀疑这是一个好主意。有没有更好的覆盖父函数的解决方案?
提前谢谢你
【问题讨论】:
标签: php wordpress themes wordpress-theming