Last active
November 22, 2023 12:13
-
-
Save kasparsd/5574458 to your computer and use it in GitHub Desktop.
Disable page title rewrite feature in WordPress SEO plugin
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 wp_title filter | |
add_action( 'init', 'remove_wpseo_title_rewrite' ); | |
function maybe_remove_wpseo_title_rewrite() { | |
global $wpseo_front; | |
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 ); | |
} | |
// Remove the title metabox from backend UI | |
add_filter( 'init', 'remove_wpseo_title_rewrite_metabox' ); | |
function remove_wpseo_title_rewrite_metabox( $metaboxes ) { | |
if ( isset( $metaboxes['title'] ) ) | |
unset( $metaboxes['title'] ) | |
return $metaboxes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An improvement of iamazik code, which avoids a PHP error when YOAST plugin is disabled: