gdrts_rich_snippets_microdata_snippet
This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!
This filter (gdrts_rich_snippets_microdata_snippet) is used to filter Rich Snippet generated data for microdata 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 the completely different structure:
- 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_microdata_snippet', 'custom__gdrts_rich_snippets_microdata_snippet', 10, 5); function custom__gdrts_rich_snippets_microdata_snippet($snippet, $method, $series, $itemscope, $item) { // modify the $snippet array // return $snippet; }