WPML GraphQL – Add Multilingual Functionality to the WPGraphQL Schema
WPML GraphQL extends the capabilities of the WPGraphQL plugin, making it the ideal solution for developers looking to create multilingual websites using front-end technologies. Experience the ease of querying and filtering content and retrieving language-specific data and translations directly from the WPGraphQL schema.
Key Features
Extend WPGraphQL with additional fields (language, language code, translations) to retrieve specific data from the WPML plugin
Filter content within the Gatsby GraphQL schema
Filter posts, taxonomies, and comments by language
Retrieve language data for objects and nodes
Query data based on all installed languages or specific languages
Works with ACF, ACFML, and WPGraphQL for Advanced Custom Fields
Required Plugins and Setup
To get started, install and activate the following plugins:
- WPML core plugin and the String Translation add-on
- WPGraphQL plugin
- WPML GraphQL plugin
If you are running a site with ACF or ACF Pro and want to expose multilingual fields from the ACF plugin to the WPGraphQL schema, install and activate:
Exploring the WPML GraphQL Schema
WPML GraphQL integrates with WPGraphQL and adds new fields and filters to the WPGraphQL schema.
Once you install the plugins, you can go to GraphQL → GraphQL IDE and use the Query Composer to easily query and filter content in different languages. This includes:
- Getting information about the language of queried objects
- Getting translations for objects like post types, taxonomies, and comments.
- Filtering the queried objects by language
As an example, the image below shows how you can retrieve a list of all posts on a WordPress site, including their language code, slug, and URI, as well as similar information for any translations of each post.
To demonstrate how WPML GraphQL works, we set up a site with English set as the default language, and Spanish and Italian as the secondary languages. Throughout this documentation page, we use this test site to query posts and the post translations created by WPML.
Reviews
Clear filtersThere are no reviews yet.