Skip to content

Instantly share code, notes, and snippets.

@mihdan
Last active June 1, 2023 01:25
Show Gist options
  • Save mihdan/bcfe0b8f74cc9d4e87da716c6368136e to your computer and use it in GitHub Desktop.
Save mihdan/bcfe0b8f74cc9d4e87da716c6368136e to your computer and use it in GitHub Desktop.
Disable breadcumbs microdata output for Yoast SEO plugin
<?php
// functions.php
add_filter( 'wpseo_schema_graph_pieces', 'remove_breadcrumbs_from_schema', 11, 2 );
/**
* Removes the breadcrumb graph pieces from the schema collector.
*
* @param array $pieces The current graph pieces.
* @param string $context The current context.
*
* @return array The remaining graph pieces.
*
* @link https://developer.yoast.com/features/schema/api/
*/
function remove_breadcrumbs_from_schema( $pieces, $context ) {
return \array_filter( $pieces, function( $piece ) {
return ! $piece instanceof \Yoast\WP\SEO\Generators\Schema\Breadcrumb;
} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment