Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
After updating the ACF for WPGraphQL plugin, nested relationship fields are returning null when querying the translation, whereas previously they returned content.
Solution:
If you're experiencing issues with nested relationship fields returning null in translations after updating ACF for WPGraphQL, we recommend checking a similar issue discussed in our forum. Please visit https://wpml.org/fr/forums/topic/wpml-graphql-with-acf-relationial-fields-doesnt-returns-data-on-non-default-language/#post-16721822 for more details. This issue might be similar to what another client experienced, and reviewing that case could provide insights or a solution.

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should these steps not resolve the issue, please do not hesitate to open a new support ticket at WPML support forum for further assistance.

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 2 replies, has 0 voices.

Last updated by duncanS-5 1 month, 1 week ago.

Assisted by: Bruno Kos.

Author Posts
January 27, 2026 at 12:50 am #17764626

duncanS-5

We have updated the version of ACF for WPGraphql the plugin has had a major update. Most of the same fields are working, however nested relationship fields are returning null when querying the translation. Where before the content would be returned. See my query in the screenshots. Is the a filter or hook that can surface this information. I have spun up a very basic WP with just the relationship field.

January 27, 2026 at 10:31 am #17766207

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

Would you be willing to provide me with WordPress credentials so I could investigate the issue directly?

Could you please paste the exact GraphQL query you’re running (as text, not a screenshot), including the part where you request the translated content?

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

I marked your next reply as private so that you can safely add credentials.

January 28, 2026 at 12:04 pm #17770350

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Can you check this?
https://wpml.org/fr/forums/topic/wpml-graphql-with-acf-relationial-fields-doesnt-returns-data-on-non-default-language/#post-16721822

I've checked this directly in your site and it may be the same issue, as that client is was using WPGraphQL for ACF. In your site we get:

"pageLayoutBlocks": {
"pageBlocks": [
{
"fieldGroupName": "PageLayoutBlocksPageBlocksPostsLayout",
"title": null,
"posts": {
"nodes": []
}
}
]
}

as well. I am also attaching the result for the query we had in that case.

16695587-20250212111946.png
January 28, 2026 at 8:20 pm #17771774

duncanS-5

Thanks for replying, unfortunately that causes issues with "Cannot access offset of type array in isset or empty",

I found a solution to the issue using this:

```php

function get_post_language_code( $post_id ) {
// Apply the wpml_post_language_details filter to get all language info for a specific post ID
$language_details = apply_filters( 'wpml_post_language_details', null, $post_id );

// Check if details were returned and extract the language code
if ( $language_details && isset( $language_details['language_code'] ) ) {
return $language_details['language_code']; // Returns the 2-letter language code (e.g., 'en', 'fr')
}

return false; // Or handle the case where the language info is not found
}

// Fix ACF relationship fields to return translated IDs
add_filter('acf/format_value/type=relationship', function ($value, $post_id, $field) {
if (empty($value) || !function_exists('wpml_object_id_filter')) {
return $value;
}

// Convert IDs to the current language equivalents
$translated_values = array();
foreach ((array) $value as $id) {
$translated_values[] = wpml_object_id_filter($id, get_post_type($id), true, get_post_language_code($post_id));
}

return $translated_values;
}, 10, 3);

/**
* When querying for relationship fields, we already have the translated IDs.
* We need to make sure WPML doesn't filter these IDs out if the current language
* doesn't match the posts being queried (which can happen in GraphQL batches).
*/
add_filter( 'graphql_post_object_connection_query_args', function( $query_args ) {
if ( is_graphql_http_request() && ! empty( $query_args['post__in'] ) ) {
$query_args['suppress_wpml_where_and_join_filter'] = true;
}
return $query_args;
}, 10, 1 );```