覆盖子主题中的类和函数

我正在写一个子主题, 需要修改父母主题的部分核心功能。

为此, 我通常会创建一个具有相同名称的新类/函数, 但是我正在使用的主题未使用

if (function_exists('function_name'))

or

if (class_exists('class_name'))

在不需要修改父主题的情况下, 我还有哪些其他选项可以覆盖此父主题。

谢谢


#1


我认为你可以找到有关优先级或在父主题函数文件中创建的具有优先级和其他功能的完整指南…。


#2


我认为, 如果你添加相同的类或函数名称, 则它取自子主题函数和类, 然后取自父主题。

对于前。

子主题

if ( ! function_exists( 'function_name' ) ) {
  function function_name(){
    echo 'This is child theme';
  }
}

家长主题

if ( ! function_exists( 'function_name' ) ) {
  function function_name(){
    echo 'This is parent theme';
  }
}

同班

来源:

https://www.srcmini02.com/67425.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_36903.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?