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)

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.