Created
July 5, 2024 13:40
-
-
Save andxbes/842379f0887613fb8bd7968ae040d4bc to your computer and use it in GitHub Desktop.
Remove author from posts (Yoast)
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 | |
//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