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

php
wordpress
#1

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.

#2

Nevermind found it (website is down)

2 Likes
Use a function to set array