gdrts_rich_snippets_jsonld_snippet

This filter (gdrts_rich_snippets_jsonld_snippet) is used to filter Rich Snippet generated data for JSON-LD rich snippet. With this filter, you can modify the snippet data before it was added to the page. There are two types of snippets generated, and they have completely different strucutre:

  • Review Rating – generated by the Stars Review method
  • Aggregated Rating – generated by the Stars Rating and Thumbs Rating methods

This filter provides 5 arguments.

Arguments

  • $snippet: this is the array with generated snippet data
  • $method: rating method
  • $series: rating series, for rating methods that use series, otherwise it is null
  • $itemscope: snippet item scope value
  • $item: the rating item for the generated snippet, it is linked to WordPress post or page

Example

add_filter('gdrts_rich_snippets_jsonld_snippet', 'custom__gdrts_rich_snippets_jsonld_snippet', 10, 5);
function custom__gdrts_rich_snippets_jsonld_snippet($snippet, $method, $series, $itemscope, $item) {
  // modify the $snippet array //
  return $snippet;
}
1
0
137
Rate this reference

You are not allowed to rate this post.

Comments

Leave a Reply