Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amboutwe/07305bb1cac21118b1168cb24fb5b2a6 to your computer and use it in GitHub Desktop.
Save amboutwe/07305bb1cac21118b1168cb24fb5b2a6 to your computer and use it in GitHub Desktop.
Remove Yoast breadcrumb from static blog page
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast breadcrumb from static blog page
* Credit: Yoast team
* Last Tested: May 12, 2021 using Yoast SEO 16.2 on WordPress 5.7.1
*/
add_filter( 'wpseo_schema_webpage', 'remove_breadcrumb_schema_ref', 10, 1);
function remove_breadcrumb_schema_ref( $piece ){
if ( !is_front_page() && is_home() ) {
unset( $piece['breadcrumb'] );
return $piece;
}
else return $piece;
}
add_filter( 'wpseo_schema_graph_pieces', 'remove_breadcrumbs_from_schema', 11, 2 );
function remove_breadcrumbs_from_schema( $pieces, $context ) {
if ( !is_front_page() && is_home() ) {
return \array_filter( $pieces, function( $piece ) {
return ! $piece instanceof \Yoast\WP\SEO\Generators\Schema\Breadcrumb;
} );
}
else return $pieces;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment