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!

  • 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.

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

  • 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.

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

The topic ‘ACF Gallery vs WPML’ is closed to new replies.