How to remove action from yoast plugin

I want remove json-ld website microdata, and I think I must disable action in the class WPSEO_JSON_LD

Action:

Read More
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;
}

Related posts

Leave a Reply

2 comments

  1. 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);