Blog
⭐️ Phát hành v4.1 với tính năng lọc dữ liệu theo ngôn ngữ cho Polylang (PRO)
Gato GraphQL v4.1 đã được phát hành. Xem ghi chú phát hành trên GitHub để biết danh sách đầy đủ các thay đổi.
Tính năng mới quan trọng nhất thuộc về Gato GraphQL PRO.
[PRO] Polylang: Lọc dữ liệu theo ngôn ngữ
Với tiện ích mở rộng Polylang, chúng ta có thể lọc dữ liệu theo ngôn ngữ.
Chúng ta có thể chỉ định ngôn ngữ cần lọc khi truy xuất dữ liệu cho:
- Posts
- Pages
- Custom posts
- Categories
- Tags
- Media items
Các trường tương ứng nhận đầu vào polylangLanguage, và chúng ta có thể lọc theo mã hoặc locale, và theo 1 hoặc nhiều hơn 1 ngôn ngữ.
Ví dụ, truyền $languageCodes: ["es"] sẽ lấy dữ liệu bằng tiếng Tây Ban Nha:
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
}
}