| 开发者 | hfranz |
|---|---|
| 更新时间 | 2026年12月4日 18:51 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.2 |
| 版权: | GPL-2.0-or-later |
| 版权网址: | 版权信息 |
en-US and https://example.com/en/about/). Simple hreflang then outputs them as <link rel="alternate" hreflang="…"> tags in the <head> of that page, including the self-referencing link to the page itself that Google recommends. Custom post types and other taxonomies can be enabled with a filter.
Features
en-UK get a warning in the editor and are never output, and spellings like en_us are corrected to en-US.<head> (or via HTTP header or sitemap), not in the visible page content. A block inserted into the content would end up in the <body> and simply be ignored. That's why this plugin deliberately uses post/term meta for the hreflang data itself, instead of a block.
Language Link block for the Navigation block
Your visitors benefit from the same data: for block themes, the plugin adds a "hreflang Language Link" block that can be inserted inside the Navigation block. Set the target language (e.g. en-US) and the block links to the current page's hreflang alternate for that language. Optionally, give it a custom label (e.g. "English" instead of en-US), an icon, and a tooltip. If the current page has no matching alternate, the menu item is left out of the navigation entirely — not just hidden.
Multisite
The plugin is fully multisite-compatible. It can be network-activated (active on every site) or activated per site individually, whichever fits your setup — each site keeps its own hreflang data, since post/term meta is already scoped per site.
sev-simple-hreflang folder to the /wp-content/plugins/ directory.There deliberately isn't one. hreflang tags must live in <head>, not in the content — a content block would be ignored by search engines.
Yes, if your theme is a block theme. Add the "hreflang Language Link" block inside the Navigation block, set the target hreflang code, and it links to the current page's matching alternate. A language code like en links to any English version (en-US, en-GB, …), a full code like en-US only to that one; an exact match always wins. Pages without a matching alternate simply don't show that menu item.
Yes. Search engines only trust hreflang annotations that are confirmed in both directions: if your German page points to the English page, the English page must also point back to the German one. Simple hreflang does not add these return links automatically, so enter the alternates on each language version of the page.
Out of the box: pages, posts, and categories, including a static front page and the static "Posts page". A front page showing your latest posts is not supported.
Custom post types and other taxonomies can be enabled with two filters, e.g. in your theme's functions.php:
add_filter( 'sev_simple_hreflang_post_types', fn( $types ) => array_merge( $types, array( 'product' ) ) );
add_filter( 'sev_simple_hreflang_taxonomies', fn( $taxonomies ) => array_merge( $taxonomies, array( 'post_tag', 'product_cat' ) ) );
Post types edited in the block editor get the sidebar panel, post types using the classic editor (such as WooCommerce products) get a meta box below the content.
A language code according to ISO 639-1 (en), optionally followed by a country code according to ISO 3166-1 alpha-2 (en-GB) and/or a script according to ISO 15924 (zh-Hant, zh-Hant-TW), or x-default. The editor warns you about invalid codes such as en-UK (the correct code is en-GB) or english; these entries are saved but not output. Different spellings such as en_us are corrected to en-US automatically.
From the site language in Settings > General (e.g. de-DE). Variants like "Deutsch (Sie)" (de-DE-formal) are output as the plain language code (de-DE). The code can't be changed in the plugin, so if you need a different one for the current site (e.g. de-AT), adjust the site language accordingly.
The self-referencing link is only output on pages that have at least one alternate; on its own, it would carry no information.
The plugin works independently of multilingual plugins and manages hreflang values manually per page/post/category. If WPML or Polylang is active and already outputs hreflang, you may end up with duplicate tags — in that case, please use only one of the two solutions.
Yes — just enter x-default as the hreflang code.
Yes. The plugin can be network-activated or activated per site; each site manages its own hreflang data independently.
Deactivating the plugin keeps your hreflang data, so nothing is lost if you reactivate it. Deleting the plugin removes all hreflang data it stored for pages, posts, and categories — on a multisite network, on every site. No other data is touched.
en now also matches regional alternates such as en-US or en-GB. An exact match always wins; if there are several regional matches, the first one is used.hreflang attribute now contains the code of the linked page (e.g. en-US) instead of the code entered in the block.sev_simple_hreflang_post_types and sev_simple_hreflang_taxonomies filters, with a meta box for post types that use the classic editor (e.g. WooCommerce products).en-UK) show a warning in the editor and are no longer output; spellings like en_us are corrected to en-US on save.de-DE-formal as a valid code (de-DE) in the self-referencing link.<head> markup being stripped by wp.org.