Created
November 26, 2024 20:30
-
-
Save robwent/a0d8e24c7f2a3724b07c2940a37d64b3 to your computer and use it in GitHub Desktop.
Remove Yoast Sitelinks Search Box Schema Piece
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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