Forked from senlin/language-independent-acf-theme-options-output.php
Last active
August 9, 2018 01:55
-
-
Save nocean/9cda534f1d7abd2294d1702f0440c0c0 to your computer and use it in GitHub Desktop.
How to get language independent ACF theme options on a WPML site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* To get this to work, you need to tinker with the acf/settings/ filter and reset the default language | |
* so that the get_field() function returns the correct results even when not on the default language. | |
* | |
* You can add the filter before you call the get_field() function and then remove it once complete. | |
* | |
* answer courtesy of James of ACF Support + love on GitHub | |
*/ | |
// Use this to stop ACF from trying to look for a language-specific version of fields. | |
add_filter('acf/settings/current_language', '__return_false'); | |
// Insert your regular ACF code between the add_filter and remove_filter lines. | |
$my_field = get_field( 'my_field', 'option' ); | |
// Use this to re-enable language-specific retrieval of ACF fields. | |
remove_filter('acf/settings/current_language', '__return_false'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can i include this in my loop?
`` $args = array(
'posts_per_page' => '999',
'post_type' => 'product',
'meta_key' => 'auszeichungen',
'meta_value' => '',
'meta_compare' => '!=',
'order' => 'DESC'
);