Skip Navigation

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
      }
    }
  }
}

For more information, you can refer to this Stack Overflow discussion.

If this solution does not seem relevant to your issue, please open a new support ticket with us.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Marcel 2 months, 3 weeks ago.

Assisted by: Marcel.

Author Posts
November 22, 2023 at 11:23 am #14896825

jackQ

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.

November 22, 2023 at 5:29 pm #14901563

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01: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

Best Regards
Marcel

November 24, 2023 at 4:18 pm #14919565

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01:00)

Hi,

thanks for the access. Can you please post the URL of the affected post so that I can compare them? Thank You!

Best Regards
Marcel

November 27, 2023 at 10:32 am #14928795

jackQ

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

November 27, 2023 at 5:20 pm #14933325

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01:00)

Hi,

thanks for the info. Let me check this with our devs. I will come back to you once I receive feedback.

Best Regards
Marcel

November 29, 2023 at 10:52 am #14949253

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01: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
      }
    }
  }
}

The Sandbox returned me

"slug": "meine-category",

Can you please let us test this on your staging environment? Then, we can try the same query as provided on https://wpml.org/forums/topic/graphql-getting-the-categories-of-other-language-post-based-on-slug/#post-14928795.

Thanks!

Best Regards
Marcel

November 30, 2023 at 1:29 pm #14963185

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01:00)

Hi,

so your issue is that from 11 categories, it returns only 10, correct?

That would be related to this: https://stackoverflow.com/questions/72902508/why-does-graphql-only-query-10-entries-when-using-custom-post-types/72903046#72903046 and is not an issue caused by our WPML Add-On.

Example:

query GetCategoryEdges {
  categories(where: {language: "th"}, first: 100) {
    edges {
      node {
        id
        slug
        name
      }
    }
  }
}

Best Regards
Marcel

November 30, 2023 at 1:57 pm #14963427

jackQ

Thanks, I figured that out.

jackQ confirmed that the issue was resolved on 2023-11-30 13:57:59.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.