如何从 yoast 插件中删除操作 [英] How to remove action from yoast plugin
本文介绍了如何从 yoast 插件中删除操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除 json-ld
网站微数据,我想我必须在 WPSEO_JSON_LD
I want remove json-ld
website microdata, and I think I must disable action in the class WPSEO_JSON_LD
行动:
add_action( 'wpseo_json_ld', array( $this, 'website' ), 10 );
我的 functions.php
中的变化:
remove_action( 'wpseo_json_ld', array( 'WPSEO_JSON_LD', 'website' ), 10 );
我做错了什么?
解决方案:
add_filter( 'wpseo_json_ld_output', 'swp_remove_jsonld_yoast', 10, 2 );
function swp_remove_jsonld_yoast($data, $context){
if($data['@type'] == 'WebSite'){
$data = false;
}
return $data;
}
推荐答案
我认为您可以更好地使用过滤器来清除该函数的输出.wpseo_json_ld_output 有过滤器.
You can better use a filter to clear the output by that function I think. There are filters for wpseo_json_ld_output.
function remove_json_ld_output( $data ) {
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'remove_json_ld_output', 10, 1);
这篇关于如何从 yoast 插件中删除操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文