Support

Account

Home Forums Add-ons Gallery Field Jetpack carousel for gallery field

Solved

Jetpack carousel for gallery field

  • Hello,

    I’ve created a simple gallery with the gallery field. Instead of linking to the image attachment I would like to have the jetpack carousel effect. Is it possible?

  • If the jetpack carousel has a shortcode you can get the images and pass them to that shortcode. Near the end of this document http://www.advancedcustomfields.com/resources/gallery/ there is an example of using the WP gallery shortcode to show the gallery that you can use as an example.

  • Thank for your help John, but I am not a coder and I’m lost. Do you know where I can start to understand that code?

  • I just read this here: http://jetpack.me/support/carousel/

    With Carousel active, any standard WordPress galleries you have embedded in posts or pages will launch a gorgeous full-screen photo browsing experience with comments and EXIF metadata.

    This means that if you have jetpack carousel active and you put your images into a WP gallery that it will automatically cause it to be a jetpack carousel.

    So the code you need is almost exactly what is in the acf gallery document I linked to above. Her it is with a little more detail and commenting.

    
    <?php 
        // replace 'gallery' below with the name of your field
        $image_ids = get_field('gallery', false, false);
        // do a little test to make sure images were added
        // to prevent php error
        if (is_array($image_ids) && count($image_ids)) {
            $shortcode = '[gallery ids="' . implode(',', $image_ids) . '"]';
            echo do_shortcode( $shortcode );
        }
    ?>
    

    If you copy and paste that into your template where you want the carousel to appear it should work.

  • Hello John,

    Thank for your help, in fact it does work, but it isn’t exactly what I’m trying to achieve. I got this design:
    Design

    Using this code:

    
    <div class="container">
    	<div class="row">
    		<?php 
    		$images = get_field('fotografias_de_artista');
    
    		if( $images ): ?>
    		<div class="col-sm-12"><h2 class="seccion">Fotos</h2></div>
    		<?php foreach( $images as $image ): ?>
    		<div class="col-sm-3">
    			<a href="<?php echo $image['url']; ?>">
    				<img src="<?php echo $image['sizes']['large']; ?>" class="img-responsive img-disco" alt="<?php echo $image['alt']; ?>" />
    			</a>
    			<p><?php echo $image['caption']; ?></p>
    		</div>
    	<?php endforeach; ?>
    <?php endif; ?>
    </div><!-- #row -->
    </div><!-- #container -->
    

    What I want is to have the Jetpack carousel for those pictures, but when I try using the code above (your post) it displays a mosaic gallery which I don’t know how to customize.

  • The documentation that I linked to was the only thing I could find about using jetpack carousel with a shortcode. I’m not familiar with this plugin at all, I actually avoid jetpack. Your best bet for getting support for more than this would be to contact their support.

  • You were right, the method that you proposed is the only one (at least that I know) that combines ACF Gallery and Jetpack Carousel. I asked Jetpack support and it is not possible to do what I asked for.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.