Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

wordpress acf image array

<?php

// Load value (array of ids).
$image_ids = get_field('gallery');
if( $image_ids ) {

    // Generate string of ids ("123,456,789").
    $images_string = implode( ',', $image_ids );

    // Generate and do shortcode.
    // Note: The following string is split to simply prevent our own website from rendering the gallery shortcode.
    $shortcode = sprintf( '[' . 'gallery ids="%s"]', esc_attr($images_string) );
    echo do_shortcode( $shortcode );
}
Source by www.advancedcustomfields.com #
 
PREVIOUS NEXT
Tagged: #wordpress #acf #image #array
ADD COMMENT
Topic
Name
7+3 =