How to remove an action from the yoast plugin

I want to delete website microdata json-ld, and I think I should disable the action in the classWPSEO_JSON_LD

Act:

add_action( 'wpseo_json_ld', array( $this, 'website' ), 10 );

Changes in mine functions.php:

remove_action( 'wpseo_json_ld', array( 'WPSEO_JSON_LD', 'website' ), 10 );

What am I doing wrong?

Decision:

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;
}
+4
source share
2 answers

You can better use a filter to clear the output with this 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);
+5
source

I got it by adding this snippet to my functions.php file

add_filter('wpseo_json_ld_output', '__return_true');
+1
source

All Articles