Php 如何删除子主题函数文件中的父主题函数文件筛选器
如何删除子主题函数文件中的父主题函数文件过滤器 功能文件Php 如何删除子主题函数文件中的父主题函数文件筛选器,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,如何删除子主题函数文件中的父主题函数文件过滤器 功能文件 function add_opengraph_doctype( $output ) { return $output. ' prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"'; } add_filter('language_attributes', 'add_opengraph_d
function add_opengraph_doctype( $output ) {
return $output. ' prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
我试着删除儿童主题,比如
remove_filter('language_attributes', 'add_opengraph_doctype');
但是它不工作。子主题的
functions.php
文件将在父主题之前运行,因此它还不会被注册
您可以等待init
操作删除过滤器
function remove_language_attributes() {
remove_filter('language_attributes', 'add_opengraph_doctype');
}
add_filter('init', 'remove_language_attributes');
子主题的
functions.php
文件将在父主题之前运行,因此尚未注册
您可以等待init
操作删除过滤器
function remove_language_attributes() {
remove_filter('language_attributes', 'add_opengraph_doctype');
}
add_filter('init', 'remove_language_attributes');
您可以在过滤器中设置优先级,如下所示:
add_filter('language_attributes', 'add_opengraph_doctype', 10);
并将子过滤器优先级设置为大于10。您可以在过滤器中设置优先级,如下所示:
add_filter('language_attributes', 'add_opengraph_doctype', 10);
并将子过滤器优先级设置为大于10。使用优先级删除过滤器,可能使用早期优先级将帮助您删除过滤器。使用优先级删除过滤器,可能使用早期优先级将帮助您删除过滤器。您好@jay!很高兴我能帮忙!如果这个或任何答案已经解决了你的问题,请考虑点击复选标记。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。我们没有义务这么做,同时也要注意,在你能够这么做之前可能会有延迟。嗨@jay!很高兴我能帮忙!如果这个或任何答案已经解决了你的问题,请考虑点击复选标记。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。没有义务这样做,同时请注意,在您能够这样做之前,可能会有延迟。