This plugin is pretty well documented at https://polylang.wordpress.com/documentation .
Switching the message language
The developer documentation states the following logic as a means to create URLs for different translations of the same post
<?php while ( have_posts() ) : the_post(); ?> <ul class='translations'><?php pll_the_languages(array('post_id' =>; $post->ID)); ?></ul> <?php the_content(); ?> <?php endwhile; ?>
If you want to influence what is visualized more, attach the pll_the_languages function and copy its behavior into your own output implementation
Website language switching
If you want the buttons to switch the language, this page: https://polylang.wordpress.com/documentation/frequently-asked-questions/the-language-switcher/ will provide you with the necessary information.
Implementation Example:
<ul><?php pll_the_languages();?></ul>
Then style with CSS to create buttons, flags, or whatever. You can also use the widget provided by the te plugin.
Getting current language
All plugin functions are described here: https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
In this case, use:
pll_current_language();
mvbrakel
source share