Support

Account

Home Forums General Issues Get Gallery Field no view images from another post Reply To: Get Gallery Field no view images from another post

  • Hi @donnafefe

    The gallery shortcode should be able to show images even if they’re not connected to the post if you pass along image ids.

    However are you aware that you need to set the second parameter of get_field to the other posts ID if you want to fetch them from another post?

    
    <?php if ( get_field('imggal', $other_post_id) ) { ?> 
        <div class="galleria">
        <?php 
        $image_ids = get_field('imggal', $other_post_id, false);
        $shortcode = '[gallery limit="3" columns="3" order="ASC" orderby="menu_order ID" ids="' . implode(',', $image_ids) . '"]';
        echo do_shortcode( $shortcode );
        ?>      
        </div>
    <?php } ?>