I want remove json-ld
website microdata, and I think I must disable action in the class WPSEO_JSON_LD
Action:
add_action( 'wpseo_json_ld', array( $this, 'website' ), 10 );
Changes in my functions.php
:
remove_action( 'wpseo_json_ld', array( 'WPSEO_JSON_LD', 'website' ), 10 );
What I am doing wrong?
Solution:
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;
}
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);
I got it working by adding this snippet into my functions.php file
add_filter('wpseo_json_ld_output', '__return_true');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With