Support

Account

Home Forums Add-ons Gallery Field ACF Gallery vs WPML

Solved

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!

    • Elliot

    • January 24, 2014 at 10:56 am

    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.

    • webloft

    • February 12, 2014 at 4:57 pm

    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.

    • MarekR

    • June 4, 2014 at 1:27 am

    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

    • MarekR

    • June 4, 2014 at 2:18 am

    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];

    • MarekR

    • July 2, 2014 at 11:27 pm

    Hey,

    Any clue why this doesn’t work: http://pastebin.com/HshgkUdt

    Thanks in advance.

  • I’ve found out that turning out the WPML Setting (WPML->Languages) “Adjust IDs for multilingual functionality” fixes the problem.

  • @webloft Thanks for the hack! it was very useful.

    • RichB

    • September 3, 2015 at 10:23 pm

    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?

    • RichB

    • August 23, 2016 at 10:44 pm

    @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; ?>
    • RichB

    • August 23, 2016 at 10:49 pm

    @daretothink Sorry ignore the above, mod please remove

  • Hi. Yep, I tried your code above, but it didn’t even display the gallery field.

Viewing 16 posts - 1 through 16 (of 16 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.