How To Create Menu For Polylang WordPress

Polylang is a Wordpress plugin which can help your website to be multi language. This plugin is not the best choice if you want full control of the site but for a free plugin it is more than good. It's very easy to install just go in the plugins section and search for Polylang, install and activate it. After this step go to the plugin settings and add your languages. First, you should add your default language because all posts will go to the default language, and then add secondary languages.

Create Menu For Polylang Wordpress

In this tutorial we will create a menu programatically, from PHP. Open your website using a FTP client like Filezilla or any other editor you use (Aptana, virtual code) and go to header.php.

In this file we will add the following bunch of code:

<?php
  $args_lang = array(
    'dropdown' => 0,
    'display_names_as' => 'slug',
    'echo' => 1
  );
  
?>
<div class="language_switcher_container">
<?php pll_the_languages($args_lang);?>
</div>

There are many other parameters you can add to the array but this is the basic you can use. Using the above code, you will create a list with all languages in site. This method is good because you customize the list as you wish using CSS. Besides of this, there are other methods to use in order to add the menu, but this one is very simple.

For more control you can choose for WPM, it's a premium plugin and it offer to you a lot of features like taxonomy translation, string translation, url and many others. Let me know if you need any help in the comments section.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x