博客
⭐️ 发布 v4.1,为 Polylang 增加按语言过滤数据功能(PRO)
Gato GraphQL v4.1 已发布。完整的变更列表请查看 GitHub 上的发布说明。
最重要的新功能属于 Gato GraphQL PRO。
[PRO] Polylang:按语言过滤数据
借助 Polylang 扩展,现在可以按语言过滤数据。
在获取以下数据时,可以指定用于过滤的语言:
- Posts
- Pages
- Custom posts
- 分类目录
- Tags
- Media items
对应字段接受 polylangLanguage 输入,支持按代码或语言区域进行过滤,并可同时过滤一种或多种语言。
例如,传入 $languageCodes: ["es"] 将获取西班牙语数据:
query FilterByLanguage($languageCodes: [String!])
{
posts(filter: {
polylangLanguages: { codes: $languageCodes }
}) {
id
title
}
pages(filter: {
polylangLanguages: { codes: $languageCodes }
}) {
id
title
}
customPosts(filter: {
customPostTypes: ["some-cpt"]
polylangLanguages: { codes: $languageCodes }
}) {
id
title
}
postCategories(filter: {
polylangLanguages: { codes: $languageCodes }
}) {
id
name
}
postTags(filter: {
polylangLanguages: { codes: $languageCodes }
}) {
id
name
}
categories(
taxonomy: "some-category"
filter: { polylangLanguages: { codes: $languageCodes } }
) {
id
name
}
tags(
taxonomy: "some-tag"
filter: { polylangLanguages: { codes: $languageCodes } }
) {
id
name
}
mediaItems(filter: {
polylangLanguages: { codes: $languageCodes }
}) {
id
title
}
}