Support » Plugin: MultilingualPress » Remove hreflang tag from the page

  • Resolved rachitarora

    (@rachitarora)


    Hi,
    I am looking to remove the following line from <head></head> tag that is added by multilingualpress plugin. Let me know if there is a setting that I can use to remove that.
    Thank you.
    ‘<link rel=”alternate” hreflang=”en-US” href=”https://www.niagaracruises.com/”><link rel=”alternate” hreflang=”fr-FR” href=”https://www.niagaracruises.com/fr/”>’

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Guido Scialfa

    (@wido)

    Hi @rachitarora in order to remove the hreflang you need to add into your child theme or within a plugin the following snippet.

    
    add_filter('multilingualpress.hreflang_type', '__return_false');
    

    This will remove the following actions:

    – add_action( ‘template_redirect’, array( $hreflang, ‘http_header’ ), 11 );
    – add_action( ‘wp_head’, array( $hreflang, ‘wp_head’ ) );

    ps. Pay attention when you copy and paste the code above, may be the quotes changes on paste. So I suggest you to do it via FTP, in case something goes wrong you can always revert the changes.

    Let us know

    • This reply was modified 9 months, 1 week ago by  Guido Scialfa.

    Hi,
    I am trying to add the line add_filter('multilingualpress.hreflang_type', '__return_false'); in the functions.php of the child theme but I still see the <link rel="alternate" hreflang="en-US" href="https://www.niagaracruises.com/"><link rel="alternate" hreflang="fr-FR" href="https://www.niagaracruises.com/fr/"> tags in the <head>.
    Let me know if I am missing anything.
    Thank you.

    • This reply was modified 9 months, 1 week ago by  rachitarora.
    • This reply was modified 9 months, 1 week ago by  rachitarora.
    Plugin Author Guido Scialfa

    (@wido)

    @rachitarora Do you have any cache active?

    rachitarora

    (@rachitarora)

    Hi @wido I dont have any cache active. If I make any other changes to the functions.php file of the child theme, I see them immediately though.
    Thanks.

    • This reply was modified 9 months ago by  rachitarora.
    Plugin Author Guido Scialfa

    (@wido)

    @rachitarora Really wired, I tried multiple time and I see the filter applied correctly. Try to put it within a plugin, basically you just need a file under wp-content/plugins with an header https://developer.wordpress.org/plugins/plugin-basics/header-requirements/ and the add_filter in it.

    rachitarora

    (@rachitarora)

    @wido I tried adding this code instead to my functions.php file and that worked

    add_filter('multilingualpress.render_hreflang', function() { return false; });

    Looks like it was a version mismatch.
    Thank you

    • This reply was modified 9 months ago by  rachitarora.

    Hi @wido , @rachitarora.

    I tried all the filters you propose (‘multilingualpress.render_hreflang’ & ‘multilingualpress.hreflang_type’) but doesn’t work.

    Anyway the redirection is not working for my site.

    I have the same problem that @pawlmichael has here: https://wordpress.org/support/topic/redirection-not-working-26/
    I have changed the priorities in the Language Manager but the redirection is not working.

    I’d read all the posts concerning this issue but I haven’t found none with a solution.

    Which could be the cause of the issue?

    Please, let me know if you could help me.

    Many thanks,
    David.

    Plugin Author Guido Scialfa

    (@wido)

    Hi @simpleswebs,

    Your problem is not related with the hreflang if your problem is the redirection.

    I would suggest you to open a different issue in order to keep the discussion here just for the hreflang.

    Btw could you check if the Redirect module of MLP is active?

    Hi @wido,

    Ok, I’ll open a new issue related with the redirection.

    Btw, the Redirect is active.

    Thanks,
    David.

    Hello,

    I have tried both of the filters. I have tried them both in functions.php and in a plugin file. Still the hreflang links appear.
    Any other ways to go?

    Plugin version is 2.11.3

    Thanks,
    Ian

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.