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

Language field do not exist in ACF options #52

Open
robert-orlinski opened this issue Jul 5, 2021 · 11 comments
Open

Language field do not exist in ACF options #52

robert-orlinski opened this issue Jul 5, 2021 · 11 comments

Comments

@robert-orlinski
Copy link

robert-orlinski commented Jul 5, 2021

Hi, I am trying to get access to the "language" field while querying ACF option fields but I am not able to do so - there is no such field and as a result, there is no way to do a query like this:

siteSettings(language: EN) {
    siteSettings {
        footerTitle
    }
}

I have the plugin installed in WordPress, along with ACF Options for Polylang, Advanced Custom Fields PRO, WP Gatsby, WP GraphQL, WP GraphQL Polylang, WPGraphQL Custom Post Type UI, WPGraphQL for Advanced Custom Fields - uninstalling singular and checking if the problem disappears does not work and that's the reason I am asking here.

From the Gatsby side, I was using both gatsby-source-wordpress and gatsby-source-graphql, and no one is showing anything like "languages" filter.

Thank you in advance for any help!

@BenjaminZekavica
Copy link

BenjaminZekavica commented Jul 17, 2021

Same here :/ I hope that the developer can fix it

@sven-ra
Copy link

sven-ra commented Dec 13, 2021

Same here.

@salmanamemon
Copy link

Facing the same issue. I hope it get fixed soon otherwise another option is to go with WPML.

@8simsim8
Copy link

Same here. On two projects it became necessary to use. Looks like I'll have to change the plugin to WPML

@sidyes
Copy link

sidyes commented Jan 16, 2022

Any Updates?

@jeanfredrik
Copy link

The plugin emits a warning if there is no explicit graphql_field_name on an options page and skips adding a language argument. My workaround was to add this filter:

use WPGraphQL\Utils\Utils;

/**
 * Makes sure that an explicit graphql_field_name name is set for each ACF
 * options page, because wp-graphql-polylang won’t add language support to it
 * otherwise.
 */
add_filter("acf/validate_options_page", function ($page) {
  if (!empty($page["show_in_graphql"]) && empty($page["graphql_field_name"])) {
    $type_name = Utils::format_type_name($page["menu_slug"]);
    $page["graphql_field_name"] = Utils::format_field_name($type_name);
  }
  return $page;
});

@brianpereradap
Copy link

@esamattis Any update on this?

@brianpereradap
Copy link

The plugin emits a warning if there is no explicit graphql_field_name on an options page and skips adding a language argument. My workaround was to add this filter:

use WPGraphQL\Utils\Utils;

/**
 * Makes sure that an explicit graphql_field_name name is set for each ACF
 * options page, because wp-graphql-polylang won’t add language support to it
 * otherwise.
 */
add_filter("acf/validate_options_page", function ($page) {
  if (!empty($page["show_in_graphql"]) && empty($page["graphql_field_name"])) {
    $type_name = Utils::format_type_name($page["menu_slug"]);
    $page["graphql_field_name"] = Utils::format_field_name($type_name);
  }
  return $page;
});

This workaround worked for me. Thanks.

@vann-at-cpcp-dot-tw
Copy link

The plugin emits a warning if there is no explicit graphql_field_name on an options page and skips adding a language argument. My workaround was to add this filter:

use WPGraphQL\Utils\Utils;

/**
 * Makes sure that an explicit graphql_field_name name is set for each ACF
 * options page, because wp-graphql-polylang won’t add language support to it
 * otherwise.
 */
add_filter("acf/validate_options_page", function ($page) {
  if (!empty($page["show_in_graphql"]) && empty($page["graphql_field_name"])) {
    $type_name = Utils::format_type_name($page["menu_slug"]);
    $page["graphql_field_name"] = Utils::format_field_name($type_name);
  }
  return $page;
});

This doesn't work. After adding this filter, although the "language" parameter can appear, no matter what value is passed to "language", the result always returns the default value.

@vann-at-cpcp-dot-tw
Copy link

vann-at-cpcp-dot-tw commented Feb 25, 2024

The plugin emits a warning if there is no explicit graphql_field_name on an options page and skips adding a language argument. My workaround was to add this filter:

use WPGraphQL\Utils\Utils;

/**
 * Makes sure that an explicit graphql_field_name name is set for each ACF
 * options page, because wp-graphql-polylang won’t add language support to it
 * otherwise.
 */
add_filter("acf/validate_options_page", function ($page) {
  if (!empty($page["show_in_graphql"]) && empty($page["graphql_field_name"])) {
    $type_name = Utils::format_type_name($page["menu_slug"]);
    $page["graphql_field_name"] = Utils::format_field_name($type_name);
  }
  return $page;
});

This doesn't work. After adding this filter, although the "language" parameter can appear, no matter what value is passed to "language", the result always returns the default value.

Add the filter by @jeanfredrik and the following line both can fix this issue.
截圖 2024-02-25 14 18 45

@predaytor
Copy link

@vann-at-cpcp-dot-tw thx man!

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

10 participants