qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
546 stars 103 forks source link

Remove hreflang #1302

Open shahmanish877 opened 1 year ago

shahmanish877 commented 1 year ago

How can we remove hreflang in head?

<link rel="alternate" hreflang="en" href="www.example.com" />
<link rel="alternate" hreflang="ne" href="www.example.com/ne/" />
<link rel="alternate" hreflang="ar" href="www.example.com/ar/" />
<link rel="alternate" hreflang="nl" href="www.example.com/nl/" />
<link rel="alternate" hreflang="fr" href="www.example.com/fr/" />

I tried function remove_hreflang_tags() { remove_action( 'wp_head', 'language_attributes' ); } add_action( 'init', 'remove_hreflang_tags' );

but that didn't do anything.

herrvigg commented 1 year ago

This has been requested in #1039 but it's a wider topic related to #668 so it's still on hold.

The language_attributes, is meant for another usage so this won't be possible with that filter.

shahmanish877 commented 1 year ago

Any other way to remove it?

On Wed, Mar 29, 2023, 3:17 AM Herr Vigg @.***> wrote:

This has been requested in #1039 https://github.com/qtranslate/qtranslate-xt/pull/1039 but it's a wider topic related to #668 https://github.com/qtranslate/qtranslate-xt/issues/668 so it's still on hold.

The language_attributes https://developer.wordpress.org/reference/functions/language_attributes/, is meant for another usage so this won't be possible with that filter.

— Reply to this email directly, view it on GitHub https://github.com/qtranslate/qtranslate-xt/issues/1302#issuecomment-1487621836, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXSF33VFL7CNDQS5FWAJT3W6NKGLANCNFSM6AAAAAAWKIHGIA . You are receiving this because you authored the thread.Message ID: @.***>

herrvigg commented 1 year ago

The output happens in: https://github.com/qtranslate/qtranslate-xt/blob/4e32d61966d614fb16f1642e030a5305f3eb3b75/src/frontend.php#L58 So you can change that locally in your website repo as a workaround.

But why do you want to remove this? If your website supports these languages you should tell the SEO where to find the alternative languages.

shahmanish877 commented 1 year ago

It's for one of my clients so I have to add what they ask. They said it's temporary.

herrvigg commented 1 year ago

If you want a quick and easy fix, add simply a return; here before the block that outputs the <link> tags. You still need the function for the echo <style> above. https://github.com/qtranslate/qtranslate-xt/blob/4e32d61966d614fb16f1642e030a5305f3eb3b75/src/frontend.php#L42

I understand this is not ideal but I prefer to come up with a proper fix and not have a filter that changes.