pll_the_languages( array( 'dropdown' => 1, 'hide_current=> 1 ) ); ?>
Polylang language switcher for WordPress Plugin
Default Language Php Code:More php code try it:
<?php
// add "raw" key and save data to variable
$langs_array = pll_the_languages( array( 'dropdown' => 1, 'hide_current' => 1, 'raw' => 1 ) );
?>
<?php if ($langs_array) : ?>
<div class="drop-block lang">
<?php foreach ($langs_array as $lang) : ?>
<a href="<?php echo $lang['url']; ?>" class="drop-block__link">
<?php echo $lang['slug']; ?>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
Polylang Language Switcher Code: A Powerful Tool for Multilingual Websites
If you're building a multilingual website, you're likely familiar with the Polylang plugin for WordPress. Polylang is a popular tool for managing content in multiple languages, allowing you to easily translate pages, posts, and other site elements. But did you know that Polylang also includes a powerful language switcher code that can greatly enhance the user experience of your site? In this article, we'll explore the Polylang language switcher code and how it can benefit your website.What is the Polylang Language Switcher Code?
The Polylang language switcher code is a piece of code that allows you to display a language switcher on your website. The switcher allows users to easily switch between different languages on your site, making it easier for them to navigate and access content. The code is included in the Polylang plugin and can be added to your site using a widget, shortcode, or PHP code.Benefits of Using the Polylang Language Switcher Code
- Improved User Experience
- Increased Engagement
- Better SEO
How to Implement the Polylang Language Switcher Code
Implementing the Polylang language switcher code is relatively simple. First, make sure you have the Polylang plugin installed and activated on your site. Then, you can add the language switcher using a widget, shortcode, or PHP code. If you're using a widget, simply go to Appearance > Widgets and drag the Polylang Language Switcher widget to your desired location. You can customize the widget settings to choose which languages to display and how to display them. If you're using a shortcode, simply add the following code to your post or page where you want the language switcher to appear:[polylang-switcher]