Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:

You are building a multilingual WordPress site using WPML with WPGraphQL and the wp-graphql-wpml bridge plugin, and you want to fetch posts in multiple languages in a single GraphQL query. However, the current schema only accepts a single language value and does not support arrays or a language_in parameter.

Solution:

Currently, the WPGraphQL + WPML setup only allows fetching posts in one language at a time. As a workaround, we recommend running separate queries for each language in one request or a single query to list all posts. Here are two examples you can try:

query {
  posts {
    nodes {
      id
      title
      uri
      date
      content
      language {
        code
      }
    }
  }
}

Or

query {
  enPosts: posts(where: { language: EN }) {
    nodes {
      id
      title
      language {
        code
      }
    }
  }
  ptPosts: posts(where: { language: PT }) {
    nodes {
      id
      title
      language {
        code
      }
    }
  }
  esPosts: posts(where: { language: ES }) {
    nodes {
      id
      title
      language {
        code
      }
    }
  }
}

For more details, refer to our documentation on querying specific posts at https://wpml.org/documentation/related-projects/wpml-graphql/#querying-specific-posts.

If this solution does not apply to your case, or if it seems outdated, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. We highly recommend opening a new support ticket if you need further assistance. You can do so at https://wpml.org/forums/forum/english-support/.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 0 voices.

Last updated by santiagoS-18 1 month, 1 week ago.

Assisted by: Bigul.

Author Posts
July 31, 2025 at 8:08 pm #17286651

santiagoS-18

Background of the issue:
I'm building a multilingual WordPress site using WPML together with WPGraphQL and the wp-graphql-wpml bridge plugin. I want to fetch posts in multiple languages in a single GraphQL query, something like: { posts(where: { language_in: [EN, PT, ES] }) { nodes { id title language { code } } } } However, the current schema only accepts a single language value (scalar), and there's no support for arrays or something like language_in.

Symptoms:
The current schema only accepts a single language value and does not support arrays or a language_in parameter.

Questions:
Is there any recommended way or planned support for filtering posts by multiple languages in one query?
If not, is there a workaround or customization you suggest (e.g. extending the schema)?

August 1, 2025 at 9:13 am #17287528

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Welcome to the WPML support forum. I will do my best to assist you in resolving the issue.

The WPGraphQL + WPML setup only lets you fetch posts in one language at a time. So, using something like this won’t work.

posts(where: { language_in: [EN, PT, ES] })

As a workaround, can you please try to run separate queries for each language in one request or a single query to list all the posts, like the following, and check whether you are getting the expected results or not

query {
  posts {
    nodes {
      id
      title
      uri
      date
      content
      language {
        code
      }
    }
  }
}

Or

query {
  enPosts: posts(where: { language: EN }) {
    nodes {
      id
      title
      language {
        code
      }
    }
  }
  ptPosts: posts(where: { language: PT }) {
    nodes {
      id
      title
      language {
        code
      }
    }
  }
  esPosts: posts(where: { language: ES }) {
    nodes {
      id
      title
      language {
        code
      }
    }
  }
}

Refer to this article for more details: https://wpml.org/documentation/related-projects/wpml-graphql/#querying-specific-posts

--
Thanks!

Bigul

August 4, 2025 at 12:32 pm #17293043

santiagoS-18

I understand.
The second option you suggested was our choice.

Thanks, Bigul.