Skip to content

Instantly share code, notes, and snippets.

@andxbes
Created July 5, 2024 13:40
Show Gist options
  • Save andxbes/842379f0887613fb8bd7968ae040d4bc to your computer and use it in GitHub Desktop.
Save andxbes/842379f0887613fb8bd7968ae040d4bc to your computer and use it in GitHub Desktop.
Remove author from posts (Yoast)
<?php
//disable author info
add_filter( 'wpseo_meta_author', '__return_false' );
add_filter( 'wpseo_schema_graph', function ($data) {
foreach ( $data as $key => $value ) {
if ( ! empty( $value['@type'] ) && $value['@type'] === 'Article' && ! empty( $value['author'] ) ) {
unset( $data[ $key ]['author'] );
}
if ( ! empty( $value['@type'] ) && $value['@type'] === 'Person' ) {
unset( $data[ $key ] );
}
}
return $data;
} );
add_filter( 'wpseo_enhanced_slack_data', function ($data, $presentation) {
$key_author = __( 'Written by', 'wordpress-seo' );
if ( isset( $data[ $key_author ] ) ) {
unset( $data[ $key_author ] );
}
return $data;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment