Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get correct response with language on Option Pages #88

Open
gmemeint opened this issue Apr 15, 2024 · 2 comments
Open

Not able to get correct response with language on Option Pages #88

gmemeint opened this issue Apr 15, 2024 · 2 comments

Comments

@gmemeint
Copy link

Hello,

I need help because I'm probably missing something, but I'm unable to get a proper reponse to retrieve multilingual Options pages correctly.

Context
Headless Wordpress with NuxtJS front-office.

I have :

  • ACF Pro
  • ACF Options for Polylang
  • WPGraphQL for Advanced Custom Fields
  • Polylang PRO
  • WPGraphQL

I create an Option pages like this:

acf_add_options_page([
    'page_title' => __('Site settings', 'theme'),
    'menu_title' => __('Site settings', 'theme'),
    'menu_slug' => 'site-settings',
    'post_id' => 'options',
    'capability' => 'manage_options',
    'redirect' => false,
    'show_in_graphql' => true,
    'graphql_field_name' => 'options'
  ]);

I have an ACF Field groups named "Options" that I have in 2 languages (FR / EN)
Each of them is exposed to GraphQL with Field Name = "options" and show if Options Page = Site settings

I am able to contribute it when I switch my language in my top bar without any problem.
I checked my database, and I see my fields with option_name :

  • options_fr_FR_banner_title (and field reference in _options_fr_FR_banner_title)
  • options_en_GB_banner_title (same)

So it seems that at this point, everything seems to work as expected.

But when I try to build my GraphQL request, I am able to see the language variable, the FR version (which is the default one) is returning the value correctly, but my EN version is always returning null. I tried to debug, but didn't find anything relevant yet.

I only saw this which seems weird (when using FR I do not see frFR concatened) :
SELECT option_value FROM panzani_options WHERE option_name = '_optionsenGB_cookies_banner_title' LIMIT 1

I found a workaround but it is not what I want in my front, if I change for my Field groups EN the graphql name from "options" to "options_en", I am able to retrieve the correct value. But it means that I have two different GraphQL fields for the same purpose.

Thanks in advance if someone has some tips :)

@PSMJonas
Copy link

PSMJonas commented Jun 5, 2024

Same issue.

@PSMJonas
Copy link

PSMJonas commented Jun 17, 2024

Fixed it in #93.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants