Does L&L work with WPML?

Hi there, I am currently managing a multi language website where the content is managed using the WPML plugin. I wanted to check, is Loops and Logic compatible with this? An example being this:

  • My website base language in English. The secondary language is Chinese
  • Posts are entered in English, and then have translations added in Chinese. So post IDs 1, 2 and 3 have a base language of English but they also have translated versions in Chinese
  • Lets say I have a category of ‘Test Category’ and post IDs 1, 2 and 3 are all assigned that category
  • Lets say I have a loop, placed inside my ‘page’ which loads all posts in the category ‘Test Category’, is it possible that if the user has selected the language to be Chinese, that the Loop will then load in the Chinese translations of the posts - but if they change the language back to English, it will display the English (base) language version of the posts?

Many thanks for your help,


Here’s a thread that has some discussion about ways of working with L&L + WPML that you might find helpful:

I think if you’re working with the default query for the page, like a plain loop on an archive, WPML would likely modify that query and return the expected posts in the expected language.
In terms of putting an arbitrary loop on an arbitrary page and having variants of posts in another language show up, I haven’t personally tried it so I’m not sure.
The easiest way to find out is to give it a try!

Others have a lot more experience here than I do with WPML and may be able to chime in.

I don’t have a ton of experience combining L&L and WPML, but I can confirm that when you’ve got WPML installed on your site, L&L templates seem to only loop through posts in the current language. So if you placed something super basic like this on your page:

  <Loop type=post>
    <li><Field title /></li>

The English version of the page containing this template would loop through English posts whereas the Chinese version would only loop through Chinese posts.

I haven’t done much more testing than this, but I can imagine there’d be a couple of caveats to using L&L with WPML:

  1. If you create a translation of a post, you’re essentially creating a completely separate post, meaning that the post IDs are different. Any templates that rely on referring to specific IDs in one language probably wouldn’t work in the other.
  2. I haven’t thoroughly tested this, but I think you’d want to be careful with string translations, since if you change any strings related to post meta or anything like that, your templates might not work in both languages. I imagine you’d want to only use WPML to translate your content but not the underlying data.

Ultimately, you can certainly use L&L to work with multilingual content in WPML, but you need to carefully consider how your template is working. If you explicitly refer to a category slug in a template, for example, you’ll need to make sure that slug exists in both languages and refers to the same (or at least equivalent) content. There might also be considerations when working with Chinese characters since you may need to make sure that the characters are valid in HTML (and therefore L&L).

1 Like