Home » Tutorials » Wordpress » Multilingual wordpress site with Polylang

Multilingual wordpress site with Polylang

multilingual wordpress site with polylang

In this tutorial I will show you how to easily translate your website with the Polylang wordpress plugin. With this plugin you can translate posts, pages, media, categories, post tags, menus, widgets and etc. And the most important – it’s free.

First make sure you are using WordPress 3.1 or later and that your server is running PHP5. Then install the plugin and activate it. Go to the languages settings page and create the languages you need (you can find them in your wordpress admin settings page).

Advertisement

That was the easy part. Now I’ll show you how to modify it in a way that you want it to look. The language bar is provided to be added as a widget or in your menu. But what should we do if we want to insert it in the header with custom position?

Paste one of these codes in your header.php file or wherever you want to add the language bar.

<?php //outputs a list of languages names ?>
<ul><?php pll_the_languages(); ?></ul>

<?php //outputs a flags list (without languages names) ?>
<ul><?php pll_the_languages(array('show_flags'=>1,'show_names'=>0)); ?></ul>

<?php //outputs a dropdown list of languages names ?>
<?php pll_the_languages(array('dropdown'=>1));  ?>

In case you choose the first one, you will need to stylize the language bar. With some simple CSS we will make the languages show on one line and without li tag dots.

.lang-item {
display: inline;
list-style:none;
}

.lang-item a {
text-decoration:none;
color:#ec008c;
}

.lang-item a:hover { color:#c90d7c; }

And finally the conditional tags or how to get the current language.

$currentlang = get_bloginfo('language');
if($currentlang=="en-US") { $post_id = 161; }
In this tutorial I will show you how to easily translate your website with the Polylang wordpress plugin. With this plugin you can translate posts, pages, media, categories, post tags, menus, widgets and etc. And the most important - it's free. First make sure you are using WordPress 3.1 or&hellip;

Review Overview

0%

User Rating: 4.62 ( 5 votes)
0

About Georgi Dyulgerov

Georgi Dyulgerov

Founder of fTutorials.com - the website aiming to keep you in touch with the latest technologies in the brand. Also a Freelance web developer.

Check Also

lost wordpress password

How to reset WordPress password from PhpMyAdmin

Nowadays, it might be very common to forget the password for your own blog. When ...

2 comments

  1. It’s not my first time to visit this web site, i am browsing this site daily and get pleasant information from here everyday.

Leave a Reply

Your email address will not be published. Required fields are marked *


Loading Facebook Comments ...