Support

Account

Home Forums Bug Reports ACF looking for translated WPML field when translations for fields disabled

Solved

ACF looking for translated WPML field when translations for fields disabled

  • I’m running the latest versions of WPML and ACF Pro.

    I have translations for Field Groups and Fields set to “Do Nothing”.

    I’m attempting to retrieve a value from an options page.

    When ACF runs its acf_get_valid_post_id function, it’s appending a language suffix to the $post_id, despite translations being disabled. I would expect it to remain “options,” but, for example, on Arabic pages it’s getting converted into options_ar.

    Is there a check missing to see if translations are desired for these fields before updating the $post_id value when viewing a translated version of a page?

  • Hi @joleksow

    Thanks for the question.

    ACF will always modify the $post_id param during save/load irrelevant of the WPML setting to translate the field groups.

    If you have an options page, and you don’t translate fiedl groups, you can still create independent values for all languages.
    This is becuase ACF modifies the $post_id with the current language string.

    I don’t I understand what the issue is here. Can you elaborate on why this is causing an issue?

  • Thanks for the response, Elliot. What I’m trying to accomplish is being able to use the same field value for all locales without having to create separate instances for each locale. Does that make sense?

    Specifically this is for an image, where it wouldn’t make sense to have different versions of it for different languages.

  • Hi @hube2

    Great find! This is perfect,

    @joleksow – I’ve also left a comment on that snippet with an even simpler way!

    Thanks
    E

  • This looks great, many thanks to you both!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.