Support

Account

Home Forums Bug Reports Bug: documentation for gallery field wrong

Unread

Bug: documentation for gallery field wrong

  • If this is my misreading, please delete this thread and accept my apologies.

    But
    https://www.advancedcustomfields.com/resources/gallery/

    mentions a return format which is not in the admin
    so the field returns an array.

    making this template usage wrong;

    <?php 
    $images = get_field('gallery');
    $size = 'full'; // (thumbnail, medium, large, full or custom size)
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image_id ): ?>
                <li>
                    <?php echo wp_get_attachment_image( $image_id, $size ); ?>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
    

    it should read

    <?php 
    $images = get_field('gallery');
    $size = 'full'; // (thumbnail, medium, large, full or custom size)
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image ): ?>
                <li>
                    <?php echo wp_get_attachment_image( $image['id'], $size ); ?>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
Viewing 1 post (of 1 total)

The topic ‘Bug: documentation for gallery field wrong’ is closed to new replies.