With Polylang Pro you have the possibility to add a language switcher in the new widget block editor introduced in WordPress 5.8. ![]() ![]() You can choose to display either the language name or its flag or both 1.3 Add a language switcher as a Block in the new widgets block editor ![]() Refer to Options for the detail of what each option of the Language Switcher. This option works with Polylang Pro for existing widgets only, it is no longer possible to add it. With Polylang you have the possibility to add our widget Language switcher, in the Appearance tab > Widgets sub-tab, by first adding a block “Legacy Widget” in which you then select the Polylang Language Switcher. Refer to Options for the detail of what each option of the Language Switcher does.ġ.2 Add a language switcher as a widget with legacy block If you don’t see the language switcher metabox, check that it is not disabled in the screen options (horizontal tab which can be unfolded as shown by bullet 3 in the “Menu” documentation). You can include the Polylang language switcher in your menu. Add a language switcher 1.1 Add a language switcher in a menu If there is no content in any language, then the language switcher does not appear at all. Note: To avoid 404 errors, the language switcher does not display a language on the front end if there is no published content (post or page) in that language. By default, if the current page is untranslated, the language switcher links to the front page in the corresponding language. The purpose of the language switcher is to create links to the translations of your current page. Displays language names and displays flags.Language switcher in the navigation block.Language switcher as a block in the FSE.Add a language switcher as a widget in the new block editor.Add a language switcher as a widget with legacy block.If you are using the flags provided with Polylang, just add the following css rule to your style. lang-item My flags are misaligned in the Twenty Eleven menu So you can add the following lines in style.css. The appearance of the language switcher is controlled by the classes “lang-item” for all languages and “current-lang-item” for the current language. The appearance of your site is controlled by CSS rules placed in the file style.css in your theme directory. How to display the widget flags horizontally? Note that your custom flags won’t be used on admin side. Once the custom flags are uploaded, go in Polylang settings and click on save changes. Don’t use the /polylang/flags/ directory as your files would be removed when automatically updating the plugin. Then upload these files in the /wp-content/polylang/ directory (create the directory if it does not exist). You have to use PNG or JPG files and name them with the WordPress locale. ![]() Can I use my own flags for the language switcher? See the documentation for theme and plugin programmers for more about the function parameters. For this, you can simply add in your theme the following instruction: It is possible to get a language switcher where you want in your theme without using the widget. Is it possible to display a language switcher without using the widget? To avoid 404 errors, Polylang does not display a language if there is no published content (post or page) in that language. I setup the language switcher but it doesn’t appear on frontend You then should have a new metabox which allows to add a language switcher just as you add another menu item. In appearance->menus, go in screen options on top right of you screen and check the “Language switcher” checkbox. I can’t add the language switcher in the menus
0 Comments
Leave a Reply. |