WordPress

Learn how to exchange posts and other items between WordPress and Lokalise with ease.

Ilya Krukowski avatar
Written by Ilya Krukowski
Updated over a week ago

This feature is available from the Essential plan and above.

Lokalise WordPress plugin allows you to import and export multilingual content.

Prerequisites

Please note that WordPress doesn't have multilingual content support out of the box therefore you'll have to install a separate plugin for that.

Currently Lokalise supports two popular multilingual plugins:

  • Polylang (only a free version is supported at the moment but we are working on supporting the pro version as well)

Lokalise WordPress plugin also supports the following plugins:

Here's a generalized scheme of how our WordPress plugin works:

Setting up WordPress plugin

Before getting started please make sure that you have already installed WPML or Polylang plugin to enable multilingual content support.

Once you are ready, follow these steps:

  1. To get started, open your WordPress admin page and proceed to Plugins > Add new.

  2. Enter "lokalise" in the search box and press Install now next to "Lokalise Companion Plugin".

  3. Proceed to Settings > Lokalise.

  4. Copy the Authorization secret key.

  5. Next, proceed to your Lokalise project and open Apps > Wordpress.

  6. Click Install.

  7. Enter your Wordpress site hostname (for instance, https://example.com/wp-json) and provide the Lokalise secret obtained at step 4.

    1. If you use WP Engine hosting, you should add a subdomain provided by WP Engine and HTTP protocol in the site hostname (for example, http://yourcompany.wpengine.com/wp-json).

    2. If you use Kinsta provider, try to connect using both http:// and https:// as due to Kinsta’s non-standard web stack and proxy the protocol we can use to authenticate Lokalise varies.

  8. Authorize Lokalise by pressing Accept.

Please note that Lokalise Companion also works with custom login pages. Custom login pages allow users to use their own logo, background, and design on login pages. The most popular plugins that allow you to create custom pages are: Loginpress, WPS Hide Login, Custom Login Page Customizer, etc.

WordPress multisite

Our plugin does have support for multisite features. Please remember that your plugin has to be activated for all sites that you'd like to translate. Also please note that currently it's not possible to translate separate locale subsites in one Lokalise project.

Custom post types

By default, WordPress comes with two basic types of content: Posts and Pages. These are called post types. However, many sites also feature custom post types. For example, a site could have Tours, Articles, or Book post types.

Our plugin does support custom post types, however, these must be made translatable.

If you are using WPML:

  • Open WordPress admin dashboard.

  • Proceed to the WPML > Settings page.

  • Scroll to the Post Types Translation section.

  • Make your custom post types translatable by selecting Translatable (only show translated items) option. Otherwise, post types will not be available for sync with Lokalise.

  • Please find more info in the WPML docs.

If you are using Polylang:

  • Open WordPress admin dashboard.

  • Proceed to Languages > Settings.

  • Find Custom post types and taxonomies section.

  • Enable custom post types that you require support for.

  • Please find more info at Polylang docs.

Once you have made custom types translatable, they'll have language attributes and can be translated with the help of Lokalise plugin.

Advanced Custom Fields

Advanced Custom Fields is a WordPress plugin which allows you to add extra content fields to your WordPress edit screens.

Supported type fields are Text, Text area, and Wysiwyg text.

ACF fields can also be translated with the Lokalise plugin. Just select them on the integration page and import them to your Lokalise project. After translations are added you can export all these translated fields back in WordPress.

Known issues

Note for Apache users

If you are using the Apache web server, you might need to update your VirtualHost configuration for the authorization flow to work correctly (it is not usually required though). Specifically, add the following line at the very beginning:

SetEnvIf Authorization "(.+)" HTTP_AUTHORIZATION=$1

Then don't forget to restart your server.

Compatibility with other WordPress plugins and limitations

  • Lokalise integration might not work correctly with some other third-party plugins, especially with drag&drop site builders like WPBakery.

  • Our plugin doesn't support Gutenberg reusable blocks. You'll need to convert these to "regular" blocks in order to properly import content to Lokalise.

  • Currently, we do not support translation of taxonomies, SEO metadata, and media.

Note for customers using firewall or various restrictions

If you're using a firewall, IP restrictions or security plugins to protect your /wp-admin pages, make sure to whitelist Lokalise origin IP addresses that can be found in this article. Please check this list regularly once in a few months as we update our IPs from time to time.

If something goes wrong

Make sure that:

  • You can open yourwebsite.com/wp-json/lokalise/v1/environment page.

  • You have enabled the WPML plugin and set it as a localization provider (visit yourwebsite.com/wp-json/lokalise/v1/environment to double-check).

  • Check that your permalink settings are set to anything but the default (otherwise REST will not work). To check it go to Settings > Permalinks and select any but Plain.

  • You can receive data via API. Visit yourwebsite.com/wp-json/wp/v2/pages and make sure that content and excerpts are not empty.

  • You can retrieve the list of locales at yourwebsite.com/wp-json/lokalise/v1/locales (the language names and language codes should not be empty or NULL).

Importing posts and pages

This app also supports automated import. You can learn more in the corresponding article.

After setting up the plugin, you will see content currently available in your Wordpress.

To translate the content, you need to import it to your Lokalise project first. Importing effectively means downloading content from Wordpress and creating new translation keys on Lokalise. These keys will then be properly connected to your WordPress content.

Note that you can find a specific element using the search box in the top right corner, or narrow the scope using the Filter dropdown:

Next, choose one or more items to import to your Lokalise project. All languages that are present in Wordpress but missing in your Lokalise project will be created automatically.

Finally, press Import selected. The import process will happen in the background, and its status can be checked on the Activity page.

Translating content

After the items are linked, you may proceed to the Lokalise project editor and work with the content as usual. All translations imported from Wordpress may have several tags:

  • Wordpress.

  • Tag named after the post or the page. To do so, you would need to add a "Title" to the "Assign tags" list during the import. With such setting, if the key belongs to the "Hello world" post, it will have a "Hello world" tag.

Managing imported items

This app also supports automated export. You can learn more in the corresponding article.

Open Wordpress app on Lokalise again to manage the currently imported items or import the new ones. You will see the list of all previously loaded items. Pick the items you'd like to upload back to Wordpress and click Export selected. Then choose one or more languages and decide whether you'd like to export empty translations:

This process will run in the background. Then return to your Wordpress and make sure the chosen items were updated properly!

Did this answer your question?