• Resolved myideasforsite

    (@myideasforsite)


    Hello! Want to remove rel canonical on custom post type single. I think your plugin is rewrite it? Tell me please what action I must to use?
    I try

    
    function remove_canonical1() {
        if ( is_singular( 'news' ) ) {
            remove_action('wp_head', 'rel_canonical', 47);
        }
    }
    add_action('wp', 'remove_canonical1');
    

    But it does not work

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Maciej Bis

    (@mbis)

    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

    Plugin Author Maciej Bis

    (@mbis)

    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.

    Thread Starter myideasforsite

    (@myideasforsite)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove canonical on custom post type single’ is closed to new replies.