Support » Plugin: All in One SEO Pack » Remove Canonical tag when noindex selected

  • Resolved solosails



    Is there a way to get AIOSEOP to remove the canonical meta if noindex meta is selected?

    I have read in a few places that this shouldn’t be done, either one or the other, however, in AIOSEOP, you can have both selected at the same time.

    Is there a way for now that one could write a conditional that removes the canonical tag if the noindex is there?

    And for future releases is it possible to make it automatic in the plugin?

    Many many thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Steve Mortiboy


    Hi solosails,

    No there is not a way to disable canonical URLs on a per page or post basis and I can’t think of a use case for us adding this as a feature. What is your use case for this? If you’re setting NOINDEX then the canonical URL really doesn’t matter and it’s ignored so there’s no reason to remove it.

    We could probably provide you some custom code you could add for this, I’ll ask our Lead Developer to respond.

    Hi there wpsmort,

    There was a post by one of the Google team members (John Mueller) saying that you shouldn’t mix rel=canonical and noindex

    However, if you guys think this is not a problem, I am more than happy to take your word for it.

    Personally, I can’t see why there should be a problem, but I have recently suffered a MASSIVE hit from google going from first page to practically invisible about a month ago and I’m very keen to make sure that there is absolutely no excuse for Google to penalise me any more!

    Thanks, Andrew

    Plugin Contributor Peter Baylies


    Hi solosails,

    I don’t think this really applies generally, as they’re talking about using canonical urls as the equivalent of a redirect vs. using noindex to not show non-canonical pages. However, it’s easy enough to support; add this code to a plugin or to the functions.php in your theme:

    global $solosails_noindex;
    $solosails_noindex = false;
    add_filter( 'aioseop_robots_meta', 'solosails_detect_noindex' );
    function solosails_detect_noindex( $robots ) {
        if ( strpos( $robots, 'noindex' ) !== false ) {
            global $solosails_noindex;
            $solosails_noindex = true;
        return $robots;
    add_filter( 'aioseop_canonical_url', 'solosails_noindex_canonical_urls' );
     function solosails_noindex_canonical_urls( $url ) {
            global $solosails_noindex;
            if ( $solosails_noindex ) return '';
            return $url;

    Hi Peter,

    Thanks once again for your amazing support.

    Do you think I should add this in or not? Currently I have tags set to noindex in an attempt to cut down duplicate content. And as mentioned this also has the canonical url listed as well.

    Very best regards, Andrew.

    Plugin Contributor Peter Baylies


    Give it a try; I don’t think it’s necessary, but it shouldn’t hurt anything, as they’re noindexed anyhow.

    Great, thanks again.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remove Canonical tag when noindex selected’ is closed to new replies.