Guest User

Untitled

a guest
Feb 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. // display current language
  4. if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
  5. echo "<pre>Current language code: ";
  6. print_r(ICL_LANGUAGE_CODE);
  7. echo "</pre>";
  8. }
  9.  
  10. // get all WPML languages
  11. $langs = icl_get_languages('skip_missing=0&orderby=KEY&order=DIR&link_empty_to=str');
  12.  
  13. // get acf option "seo_title" in all languages
  14. foreach ($langs as $lang) {
  15. // modify current language
  16. add_filter('acf/settings/current_language', function() {
  17. global $lang;
  18. return $lang['code'];
  19. });
  20.  
  21. echo "<pre>seo_title [{$lang['code']}]: ";
  22. print_r(get_field('seo_title', 'option'));
  23. echo "</pre>";
  24. }
  25.  
  26. // reset to original language
  27. add_filter('acf/settings/current_language', function() {
  28. return ICL_LANGUAGE_CODE;
  29. });
Add Comment
Please, Sign In to add comment