Home Forums ACF PRO WPML: Get field from options from specific/other-than-active languages


WPML: Get field from options from specific/other-than-active languages

  • Hi there,

    I thought this must be possibly by just switching languages, but apparently it doesn’t:

    I have a (non-translated, i.e. each language ‘fills’ the same options fields) options field group, and referencing those fields e.g. in a footer does work neatly – it pulls the right version of the option on every language. As soon as I try to get a specific language’s field it still always returns the current language’s field content.
    For example:
    I use do_action( 'wpml_switch_language', 'de' ); to switch language to ‘de’. Normally, after that switch I should be able to grab fields from that specific language, no? Or retrieve a custom field for that very page I am on, but it still only gets data from the active language.

    Is there something wrong in my thinking? I have read all the other related posts, but to no avail. Since my options page is old (the project is), I didn’t strive to translate it, so I have identical option field names in all languages.

  • There is a topic here that may help you, it deals with the default language, but I think it can be used to set any language before getting a field

  • Hey John, thanks for the link (and sorry for the delay in responding)! Is there a way via acf_get_setting to not only get the current or default language, but a language of choice?

    What I actually need and am working on is a foreach loop through all WPML languages and the retrieval of a specific field from the options for each of the languages, to be exact.

    Thank you in advance!

  • ciao physalis

    i had the same issue just now, using do_action( 'wpml_switch_language', $language ); to change language in an ajax call. but acf options was always returning the ‘original’ language, that was loaded on the inital load.

    i now also added this right after the do_action call:
    add_filter('acf/settings/current_language', 'jnz_acf_set_language');

    and here is the corresponding function:

    function jnz_acf_set_language() {
        return apply_filters( 'wpml_current_language', null );

    this sets the acf language to the current language, but you could also simply return ‘en’ or whatever you prefer..

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

The topic ‘WPML: Get field from options from specific/other-than-active languages’ is closed to new replies.