Views: 201
Newer versions of Yoast ingnored this code. Tested on Yoast 15.0
// Disable Canonical for - ALL pages
function remove_canonical() {
add_filter( 'wpseo_canonical', '__return_false', 10, 1 );
}
add_action('wp', 'remove_canonical');
I fixed it with a filter priority value. Here’s working code:
// Disable Canonical for - ALL pages
function remove_canonical() {
add_filter( 'wpseo_canonical', '__return_false');
}
add_action('wp', 'remove_canonical', -19999);
Because new Yoast versions (like 15.0) use the negative priority to handle wpseo_head in the plugin file front-end-integration.php:
\add_action( 'wpseo_head', [ $this, 'present_head' ], -9999 );
Source : Stackoverflow