Wordpress - Custom strings for translation using Polylang plugin

Use this


on functions.php

Use it like this:


Allows plugins to add their own strings in the “strings translation” panel. The function must be called on admin side (the functions.php file is OK for themes).

pll_register_string($name, $string, $multiline);
‘$name’ => (required) name provided for sorting convenience (ex: ‘myplugin’)
‘$string’ => (required) the string to translate
‘$multiline’ => (optional) if set to true, the translation text field will be multiline, defaults to false


pll_register_string('Header Title', 'The title you want to appear');

Then on dashboard config, on languages, you are going to find a tap called "strings". There you're going to have this new created string, and an input text to fill the translation text for every active language on your site. Write translations, and then use the funcions:

pll_e() to directly echo, or pll__() to manually echo it. Your'ge going to use it like:

pll_e('The title you want to appear'); or
echo pll__('The title you want to appear');

That's it! :)