Support

Account

Home Forums Add-ons Options Page WPML and ACF Options Reply To: WPML and ACF Options

  • @flashpunk: here is how i did it:

    1) Created a custom post type, named my_settings. Obviously, is translatable by WPML
    2) Created a page template for each settings page. Fortunate, i had only two pages. So, now we have tpl-home_carousel.php and tpl-other_options.php
    3) Created a page for each template. For now it’s enough to have them in base language (english)
    4) Created an option page that sets the id’s for these pages. (there is a post object or something like this; you need the ID) (for the sake of simplicity, i named all options here as wpml_*). We need this only for base language.
    5) The old option pages (those with real … options) are now set as to be displayed on certain templates (those that we set earlier)

    Done with admin!

    Right now, we need a way to get the id for get_field('our_awesome_setting', ID) function.

    We first get the ID for base language page:
    $home_carousel = get_field( 'wpml_options_home_carousel_page', 'option' );

    We then get the translated page (or base page if there is no translation):
    $home_carousel_id = icl_object_id( $home_carousel->ID, 'my_settings', true, ICL_LANGUAGE_CODE );

    Then we set a constant with this translated ID:
    define( 'MY_OPTIONS_HOME_CAROUSEL', $home_carousel_id );

    After this, everything is just fine. We can get fields as usual, but instead of using option param, you use this constant we defined earlier:

    $gallery_rows = get_field( 'home_gallery_rows', MY_OPTIONS_HOME_CAROUSEL );

    Done!

    (let me know if i explained well)

    Very, very late edit: you can set templates to custom post types by using this plugin: http://wordpress.org/plugins/custom-post-type-page-template/