Home›Support›English Support›[Resolved] GraphQL: getting the categories of other language post based on slug
[Resolved] GraphQL: getting the categories of other language post based on slug
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing an issue where a GraphQL query does not return all the expected categories for a specific language (Chinese Simplified), while it works for other languages like Chinese Traditional and Japanese. Solution: We have identified that the issue is not caused by our WPML Add-On but is related to GraphQL's default behavior of returning only a limited number of entries. To resolve this, we recommend modifying the query to specify a higher number of entries to be returned. Here is an example of how to adjust the query:
query GetCategoryEdges {
categories(where: {language: "th"}, first: 100) {
edges {
node {
id
slug
name
}
}
}
}
thanks, the php code helps. but I m facing another issue getting the categories of other language post based on slug. Please refer to attached image. the query works when the slug is in English.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: Europe/Madrid (GMT+02:00)
Hi,
do you have a staging environment where we can make some tests? I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to a testing site where the issue is replicated.
You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.
Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” or "All in One WP Migration" on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.
IMPORTANT
-Please make a backup of site files and database before providing us access.
-If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link
Hi, let me rephrase the question. When using this query:
query GetCategoryEdges {
categories(where: {language: "zh-hans"}) {
edges {
node {
id
slug
name
}
}
}
}
I am not able to get one of the category: hidden link
but you can see it works for zh-hant: hidden link
for Japanese:hidden link
this same issue happens with a few other catgories. Thanks
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: Europe/Madrid (GMT+02:00)
Hi,
we tried
query NewQuery {
post(id: "test-de", idType: SLUG) {
title
uri
id
categories {
edges {
node {
id
name
}
}
}
}
}
and found that the slug needs to be different. So 2x "test" slugs were not working, but if I changed one to "test-de", then yes.
We could not replicate the issue with this query. The output worked for both languages. So this also needs to work on your server. You can test it here: hidden link.
query GetCategoryEdges {
categories(where: {language: "de"}) {
edges {
node {
id
slug
name
}
}
}
}