• I’m trying to create a custom Gutenberg block using ACF, creating a slideshow and slide block. The slide block can only be used inside the slideshow block and the slideshow block can only contain slide blocks, so I’m using InnerBlocks to achieve this.

    For the functioning of the slideshow I want to use Slick Slider and add data-attributes to the slider that contain the values from the custom field that are added to the slideshow block. In order for the slider to work, I need the following setup:

    <div class="omg-block-slider" data-slick="{'slidesToShow': 2}">
        <div class="omg-block-slide">
            ...
        </div>
        <div class="omg-block-slide">
            ...
        </div>
        <div class="omg-block-slide">
            ...
        </div>
    </div>

    in my block file for the slideshow I added this:

    <div class="omg-block-slideshow" data-slick="{'slidesToShow': <?php echo $slides_desktop ?>}">
        <?php $allowed_inner_blocks = ['omg/omg-slide']; ?>
        <InnerBlocks allowedBlocks="<?php echo esc_attr(wp_json_encode($allowed_inner_blocks)); ?>" />
    </div>

    On the front-end, the above translated to this:

    <div class="omg-block-slider" data-slick="{'slidesToShow': 2}">
        <div class="acf-innerblocks-container">
            <div class="omg-block-slide">
                ...
            </div>
            <div class="omg-block-slide">
                ...
            </div>
            <div class="omg-block-slide">
                ...
            </div>
        </div>
    </div>

    For Slick slider to work with the data-attributes, the attributes need to be added to the slider element. In this case I need the slider element to be ‘.omg-block-slider’, but according to the generated setup ‘.acf-innerblocks-container’ becomes the slider element. I can’t add the data-attributes to the innerblocks-container, it just gets ignored.

    I’ve been thinking it over quite some time but can’t get my head around it. Is there a way to solve this?

Viewing 1 replies (of 1 total)
  • Plugin Support ACF Support

    (@acfsupport)

    Hi @thessav

    ACF Support Team here. This forum is generally used by ACF users to help each other out. 

    However, we would love to continue investigating and troubleshooting this issue, please can you create a ticket using our ?support form and we can look into it further.

Viewing 1 replies (of 1 total)
  • The topic ‘InnerBlocks without extra wrapper’ is closed to new replies.