Stars: 108
Forks: 19
Pull Requests: 36
Issues: 48
Watchers: 4
Last Updated: 2023-04-19 18:37:49
WPGraphQL Polylang Extension for WordPress
License: GNU General Public License v2.0
Languages: PHP, Shell, Dockerfile
Extend WPGraphQL schema with language data from the Polylang plugin.
For posts and terms (custom ones too!)
language
and translations
fieldslanguage
where argumentRoot queries
defaultLanguage
get the current default languagelanguages
list all configured languagesMenu
For details please refer to the generated docs in GraphiQL.
Example showing all features
query PolylangExample {
# Filter pages by language. If not set it defaults to ALL
pages(where: { language: EN }) {
nodes {
title
# Get language of each page
language {
code # Language code
name # Human readable name of the language
}
# Get links to the translates versions of each page
# This is an array of post objects
translations {
title
link
language {
code
}
}
}
}
# Taxonomies such as tags can be filtered like post objects
tags(where: { language: EN }) {
nodes {
name
language {
code
name
}
}
}
# Get translated version of a given menu
menuItems(where: { language: EN, location: FOOTER_MENU }) {
nodes {
url
}
}
# Get the default language
defaultLanguage {
name
code
}
# Get all configured languages
languages {
name
code
}
# Get translations for ACF Options Pages.
# See the section in the README.
siteSettings(language: EN) {
siteSettings {
footerTitle
}
}
}
If you use composer you can install it from Packagist
composer require valu/wp-graphql-polylang
Otherwise you can clone it from Github to your plugins using the stable branch
cd wp-content/plugins
git clone --branch stable https://github.com/valu-digital/wp-graphql-polylang.git
In addition to WPGraphQL and Polylang plugins you'll need these plugins too
You can install the free plugins using Composer. You'll need to have the WordPress Packagist repository enabled.
composer require wp-graphql/wp-graphql-acf wpackagist-plugin/acf-options-for-polylang
When registering the Options Page you must pass in show_in_graphql
and
graphql_field_name
arguments.
acf_add_options_page([
'page_title' => __('Site settings', 'theme'),
'menu_title' => __('Site settings', 'theme'),
'menu_slug' => 'site-settings',
'capability' => 'manage_options',
'redirect' => false,
'show_in_graphql' => true,
'graphql_field_name' => 'siteSettings'
]);
You can find us from the WPGraphQL Slack on the #polylang
channel.
But I'm using WPML?!
There's rburgst/wp-graphql-wpml.
Or you might want to checkout migration docs
https://polylang.pro/how-to-switch-from-wpml-to-polylang/
Checkout CONTRIBUTING.md