wp-graphql-wpml
wp-graphql-wpml copied to clipboard
Querying Options Pages
Is it possible to query option pages (created with ACF) in different languages?
I am not sure what you mean by option pages.
https://www.advancedcustomfields.com/resources/options-page/
Admin option pages.
I figured out how to make this work. I'll make a fork
PRs are always welcome!
@Ninodevo how did you solve getting Option pages from all languages?
@simongoot I've created a CPT "option pages" and had them translated I didn't manage to get ACF Options Pages in other languages
Any progress on getting options pages translated @rburgst ?
I'm hoping someone made some progress on this since. Would it be possible to add a "where" argument to options page queries like they exist for custom post types? That way, one could query the options given a specific language.
Really need this functionality. Any progress/solution?
I'm trying to make this work in a fork. There don't seem to be any hooks in the WP GraphQL for ACF code to hook into the options pages anywhere. I tried to add a wpmlLanguage argument to each options page field, by deregistering and re-registering the options pages fields. This doesn't work because the fields seem to lose their ACF group resolvers (which are programmatically registered after the options page fields are), so all fields inside a group return null when using this method.
If anyone can help to come up with a working fix, that'd be appreciated. My next step / attempt will be to try to manually register all options pages again and then run the code from WP GraphQL for ACF to add the groups to the options page fields.
https://github.com/Ririshi/wp-graphql-wpml/commit/74e0c6ba86a5c0c3a5a46478139b01867032b778
Imho unregistering Graphql fields won’t achieve a lot. You need to see how the data is loaded within WordPress and what wpml is doing to prevent all options to appear. Then you need to check whether there is a way to prevent wpml from doing that. Typically this is done by overwriting some wpml state variables. this is why debugging and trying to implement features like this is so very tedious and time consuming.
Normally, the query for an options page returns only one page, there is no way to return all options pages at once. So each of those queries returns one page, in the default language. My goal is to add an argument to each of those queries, and use the argument to change the active language in WPML / sitepress. At least for my usecase, it should function similarly to PR https://github.com/rburgst/wp-graphql-wpml/pull/32.
I just managed to solve this issue, quite simply. The issue I encountered previously was caused by me missing a line of code that sets the type of the options page to "options_page", while registering the options page fields again. I created a PR https://github.com/rburgst/wp-graphql-wpml/pull/42. Hoping it can be merged quickly with a tag version bump, so we can use the official package in our project :)
For those who need this functionality, you can use this branch on my fork until the PR is accepted.
+1