Hi @myideasforsite,
My plugin filters the permalink used in the canonical meta tag. It does not add the tag to HTML code, this is probably done by some 3rd party plugin. Do you use Yoast SEO, RankMath or similar SEO plugin?
Regards,
Maciej
Hi again @myideasforsite,
I am not certain what solution do you use, so I prepared “all-in-one” solution:
function remove_canonical_meta_tag() {
if(is_singular('news')) {
// Native WordPress canonical metatag
remove_action('wp_head', 'rel_canonical');
// Rank Math
add_filter('rank_math/frontend/canonical', '__return_false');
// Yoast SEO
add_filter('wpseo_canonical', '__return_false');
// SEOPress
add_filter('seopress_titles_canonical', '__return_false');
}
}
add_action('wp', 'remove_canonical1');
I guess that your code does not work, because of ’47’ priority number. Normally, ‘rel_canonical’ function is hooked with standard priority – 10.
hello. thanks for answer. yes I use yoast. Also try hook
add_filter('wpseo_canonical', '__return_false');
But it does not work to. Try to disabled this plugin. But canonical show anyway. Theme is my develop. and I did not write hardcode canonical. Its weird.