We need some of our blogs to support multiple languages.
Polylang offers this in a reasonable way for free.
There’s a paid version, and unfortunately they put support for setting up the language switcher widget from the WordPress block editor behind the paywall. But there’s a way to add it for free.
This PHP function outputs the needed HTML:
Then a plugin that supports running PHP code as a shortcode can serve as the bridge. I went with WPCode since it’s extremely popular and is well-maintained, but if that turns out to be too heavy, other plugins can do this.
Then it’s a matter of adding a shortcode block to the desired spot in the block editor, and putting in the new shortcode.
Leave a Reply