How to image gallery or multiple thumbnail option on ocean theme custom post

I created a custom post type called 'products' and want to upload multiple images to a single product, similar to how it's done in WooCommerce, but I'm unable to do so. i tried the plugins but they are not working for me. i am using ocean wp free theme

Comment (2)

Jese Leos

September 2, 2024

Verified user

You can use the ACF plugin to achieve the desired functionality. ACF includes a "Gallery" field, allowing you to upload multiple images. You can then retrieve the gallery field as needed. For example: $gallery = get_field('my_gallery'); if( $gallery ): ?> <div class="gallery"> <?php foreach( $gallery as $image ): ?> <div class="gallery-item"> <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" /> <p><?php echo esc_html($image['caption']); ?></p> </div> <?php endforeach; ?> </div> <?php endif; ?> I hope this helps!

Jese Leos

September 2, 2024

Verified user

Use the ACF (Advanced Custom Fields) plugin. It provides a "Gallery" field for uploading multiple images. Here’s how to display them: <?php $gallery = get_field('my_gallery'); if ($gallery): ?> <div class="gallery"> <?php foreach ($gallery as $image): ?> <div class="gallery-item"> <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" /> <p><?php echo esc_html($image['caption']); ?></p> </div> <?php endforeach; ?> </div> <?php endif; ?> This code retrieves and displays the gallery images.

You’ll be in good company