Support » Plugin: ACF Options For Polylang » Way to get options content for specific language

  • Hey team,

    I’ve been using your plugin to great satisfaction. But I have a situation now where I need to go around your plugin and get all acf options content for all languages in PHP, without your automatic language selection behaviour. That way I can apply some logic in the frontend.

    I’m looking for a way to bypass the acf methods that your plugin has modified, and use the original ones where I can set a language myself. Does your plugin have some kind of helper method or parameter for this? Or can you point me in the right direction how to achieve this? The only other way I can think of is to remove your plugin and do a whole other manual multi language acf options approach, but that would be a lot of work.

    Thanks in advance!
    Bram

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter bramchi

    (@bramchi)

    I think I can loop over pll_the_languages() and construct a derived option name to use with get_option() to get the content straight from the wp_options table. But maybe you know a cleaner and easier way.

    Ben

    (@runpixelrun)

    @bramchi Did you manage to figure this out? I’m stuck on the same.

    Thread Starter bramchi

    (@bramchi)

    @runpixelrun Nope, in the end I didn’t need it any more (thankfully :-).

    Have you tried looking up the option names in the database of the items that you are after? I think recreating those with the some help of the raw array of languages might still be a viable approach.

    aleksandarstojsin

    (@aleksandarstojsin)

    Pretty simple solution:

    add_filter( 'acf/validate_post_id', 'skip_acf_polylang_options', 10, 2 );
    $my_field = get_field( 'my_field', 'options' );
    remove_filter( 'acf/validate_post_id', 'skip_acf_polylang_options' );

    And the actual filter function:

    function skip_acf_polylang_options( $future_post_id, $original_post_id ) {
    	return $original_post_id;
    }

    This way you can skip overridden options name…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Way to get options content for specific language’ is closed to new replies.