Home › Forums › Add-ons › Gallery Field › ACF Gallery vs WPML
Hi, i’m having this issue in this combination: when cloning a post into a new language, the gallery field will display original post gallery in admin but, on frontend, will display exactly nothing.
The weird thing goes here: if i’m using get_field( ‘gallery’, 7463 ) on original post (that is id 7463), the field is populated. If i’m using the same get_field( ‘gallery’, 7463 ) on cloned(translated) post, the array returned is… empty.
The weirdness doesn’t stop here! If i’m adding a new item to translated gallery (without removing the one from cloning), on backend will all be displayed, but on frontend will only be displayed the added!
Any idea what i’m doing wrong?
Thanks!
Hi @iamntz
Thanks for the bug report. This is quite an od issue and one which I will need to do some testing. Leave it with me and I’ll get back to you soon.
For now, if you want, you can do some debugging of your own in the gallery field code.
Cheers
E
Great, thanks!
Unfortunately, i’m under a very tight deadline and can’t start fiddling, probably next month i’ll have some spare time.
I’m having the same problem…did someone find a solution ?
http://wpml.org/forums/topic/no-more-image-media-translation-module-with-acf-gallery-field/
Thank you.
Elliot,
Any updates on that issue ? I have an exact same problem.
Thanks.
Hello MarekR.
I’ve fond a small hack.
Because the pictures are the same in both language this little snippet will get the images from the default language.
global $sitepress;
$current_language = $sitepress->get_current_language();
$default_language = $sitepress->get_default_language();
$sitepress->switch_lang($default_language);
$images = get_field(‘album_photo’);
$sitepress->switch_lang($current_language);
$imagesCount = count($images);
Cheers
Hi,
Unfortunately the alt and title tags need to be translatable in each language.
Do a “split|explode”
$tags= $image[‘alt’] // “French tag|English tag”;
$title=explode(“|”,$tags);
$titleFR = $array[0];
$titleEN = $array[1];
I’ve found out that turning out the WPML Setting (WPML->Languages) “Adjust IDs for multilingual functionality” fixes the problem.
Much shorter function here, does the same thing and pulls in the images from the original posts gallery:
global $sitepress;
$current_main_id = icl_object_id( get_the_id(), 'post', true, $sitepress->get_default_language() );
$images = get_field('gallery', $current_main_id);
Realise this is an old post but I’ve tried using the following code:
<?php
global $sitepress;
$current_main_id = icl_object_id( get_the_id(), 'post', true, $sitepress->get_default_language() );
$awards_images = get_field('our_wines_awards', $current_main_id);
if( $awards_images ): ?>
<ul class="press awards cf">
<?php foreach( $awards_images as $awards_image ): ?>
<li>
<img src="<?php echo $awards_image['sizes']['large']; ?>" alt="<?php echo $awards_image['alt']; ?>" />
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
But it still seemingly displays the images in a completely random order.
Am I doing something wrong in my code?
@daretothink
Try the following, I think its failing because the id and image vars are outside your loop:
<?php
global $sitepress;
if( $awards_images ): ?>
<ul class="press awards cf">
<?php foreach( $awards_images as $awards_image ):
$current_main_id = icl_object_id( get_the_id(), 'post', true, $sitepress->get_default_language() );
$awards_images = get_field('our_wines_awards', $current_main_id);
?>
<li>
<img src="<?php echo $awards_image['sizes']['large']; ?>" alt="<?php echo $awards_image['alt']; ?>" />
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Hi. Yep, I tried your code above, but it didn’t even display the gallery field.
The topic ‘ACF Gallery vs WPML’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.