This can be useful if you need to point a specific language to a different staging address or perhaps are working with a headless WordPress integration where the CMS is installed on a different URL to the frontend. In the example below, we show how it is possible to unset a language (AU in this case) or modify URLs using str_replace() to change subdomain instead. Otherwise it will be defined by the type. ![]() The following code snippet modifies the $languages variable which contains an array of active languages, before returning the modified array. We could either add the shortcode directly in the header.php or the includes > helper-main-menu.php file, or use the available hooks inside the mentioned template. As their names suggest, the first filter is responsible for the icl_get_languages() function that can be used to manually retrieve a list of active languages on a WPML site while wpml_head_langs is the function that builds the hreflang tags in the site header. There is a shortcode called wpmllanguageselectorwidget that we could use to display the language switcher inside the header beside the mobile menu. It also affects the hreflang tags at the same time, allowing you to modify the list of languages that are referenced within the site code with one easy filter.Īs you’ll see below, we add this filter to icl_ls_languages and wpml_head_langs. 5.8K views 1 year ago In this tutorial we will be using 3 plugins, that you can find below, Elementor, Elementor PRO and WPML (WordPress Multilingual Plugin) one of the most common language. The following snippet will allow you to modify or remove language URLs from the WPML language switcher as well as the icl_get_languages() function which you may be using to build your own language switcher. This usually falls out of the purpose of our Support Policy as it requires custom coding but taking into consideration that it was not too complex to accomplish, I wanted to help you with it. ![]() You may be in the progress of populating a new language on the site and not yet be ready for it to be referenced in the language switcher or within the hreflang tags that are automatically added to the header of each page for search engine discovery. Languages: English (English ) Timezone: Europe/Bucharest (GMT+03:00) Hi there. There are a few scenarios in which you may want to hide a particular language from your WordPress site using WPML for multi-language content. Give the menu a name, make sure the Language and Translation of options are correct, select the proper display location from Menu Settings and proceed to add. ![]() WPML: hide or rewrite language URLs in language switcher and hreflang tagsĪmend the list of languages used by WPML’s language switcher, icl_get_languages() function and hreflang tags Last Updated: 24th August 2020
0 Comments
Leave a Reply. |