Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hreflang #1302

Open
shahmanish877 opened this issue Mar 28, 2023 · 5 comments
Open

Remove hreflang #1302

shahmanish877 opened this issue Mar 28, 2023 · 5 comments
Labels
core Core functionalities, including the admin section duplicate This issue or pull request already exists enhancement New feature or request

Comments

@shahmanish877
Copy link

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
Copy link
Collaborator

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.

@herrvigg herrvigg added enhancement New feature or request core Core functionalities, including the admin section labels Mar 28, 2023
@shahmanish877
Copy link
Author

shahmanish877 commented Mar 29, 2023 via email

@herrvigg
Copy link
Collaborator

The output happens in:

echo '<link hreflang="' . $hreflang . '" href="' . $href . '" rel="alternate" />' . PHP_EOL;

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.

@herrvigg herrvigg added the duplicate This issue or pull request already exists label Mar 30, 2023
@shahmanish877
Copy link
Author

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

@herrvigg
Copy link
Collaborator

herrvigg commented Apr 5, 2023

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionalities, including the admin section duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants