Skip to content

Instantly share code, notes, and snippets.

@robwent
Created November 26, 2024 20:30
Show Gist options
  • Save robwent/a0d8e24c7f2a3724b07c2940a37d64b3 to your computer and use it in GitHub Desktop.
Save robwent/a0d8e24c7f2a3724b07c2940a37d64b3 to your computer and use it in GitHub Desktop.
Remove Yoast Sitelinks Search Box Schema Piece
<?php
/**
* Remove the SearchAction schema from the graph.
*/
add_filter( 'wpseo_schema_website', function( $website ) {
if ( isset( $website['potentialAction'] ) && is_array( $website['potentialAction'] ) ) {
foreach ( $website['potentialAction'] as $key => $action ) {
if ( isset( $action['@type'] ) && $action['@type'] === 'SearchAction' ) {
unset( $website['potentialAction'][$key] );
break;
}
}
}
return $website;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment