Changing Yoast ld+json string (Wordpress, Yoast, PHP)

Hey Everybody,

Since the new update from Yoast it is not possible to edit the ld+json string (structured data). Using this function:

  public function update()
    {
        add_filter('wpseo_json_ld_output', [$this, 'change_yoast_ld_json_file'], 10, 1);
    }

    public function change_yoast_ld_json_file($data)
    {

        $data[] = 'add some data';
        return $data;

    }

When I dump the $data ill get this:

  ["_deprecated"]=>
  string(105) "Please use the "wpseo_schema_*" filters to extend the Yoast SEO schema data - see the WPSEO_Schema class."
}

Talking about the wpseo_schema_* filter. To be honest, I cannot really find any information about that :confused:. How can I edit this JSON string, without forcing to buying the Yoast local.

Nevermind found it (website is down)

https://webcache.googleusercontent.com/search?q=cache:8zs2mNDq6HsJ:https://developer.yoast.com/schema-documentation/api/+&cd=1&hl=nl&ct=clnk&gl=nl

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.