Integrate with WPML or Polylang
The Multilingual add-on supports normal translations, as well as dynamic strings (e.g. facet placeholder text) via the WPML String Translation plugin.
The add-on supports sub-site (fr.mysite.com) and sub-directory (mysite.com/fr/) permalinks, but does not support URL strings (?lang=fr).
In order for WPML to work well with FacetWP, you need to correctly set up the Post Types Translations in WPML’s settings. Go to:
WPML > Settings > Multilingual Content Setup
Then scroll down to the “Post Types Translation” table.
For each post type that you are using in post listings with facets, make sure you select the first option: “only show translated items”:
The second option, “use translation if available or fallback to default language”, does not work well with FacetWP. If you select that option and you have posts without a translation, you will have the fallback (original language) posts in the translated language results, and those posts will have their (original language) categories/terms indexed. This will result in duplicate categories/terms showing up in facets: in the translated language and in the original language.
Keep in mind that when FacetWP indexes a post, it determines that post’s language and indexes any related content for that language. FacetWP does not support the concept of a single post belonging to multiple languages, so you essentially need to have a translated post for each language. If a translation is not available, you need to duplicate the post in the original language.
If you encounter any issues with WPML, like posts, terms or other data not appearing, make sure your WordPress install has enough memory. WPML’s minimum requirements are 128M, and 256M is recommended.
In our performance tuturial you can read how to give WordPress more memory.
You can see how much memory is currently set by going to WPML > Support. In the WordPress section, you’ll see what is set as WordPress’ memory limit. This has to be lower or equal to what is available on the server, which you can see in the PHP section under “Memory limit”.
If you go to WPML > Support > Troubleshooting, you’ll see a lot of buttons with which you can clean up WPML’s cache and database. Make sure you have a database backup before using that.
The Multilingual add-on supports normal Polylang translations.
Polylang Pro comes with a feature that makes it possible for posts, pages or terms to share the same slug across translations.
Currently, this feature does not work with FacetWP. With shared slugs, on pages with the non-default language facets will not return expected options.
The solution for now is to use unique slugs across translations.
FacetWP has a set of strings that cannot be translated with
_e(), because these strings are dynamic, “in-database” strings, which WPML or Polylang cannot access. These strings are mostly labels used in various facet types.
Fortunately, there is a way to translate these strings: with the facetwp_i18n hook.
If you are using WPML or Polylang together with SearchWP, make sure to install the appropriate SearchWP integration extension:
These extensions will limit search results to the active language of the page. Without them, there will be a disconnect between the facets, their counts and the post listing.
- Fixed minor code cleanup / modernization
- Fixed the correct element_type was not being passed into WPML (props Bram)
- Fixed reset WPML language after indexing
- Fixed make sure Polylang language variable is defined
- Fixed WPML class name (props Derrick Hammer)