Tagged: , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1469273

    Not sure why I thought it was going to be easy, but I suppose that is the kiss of death.

    Is there a relatively easy way to use either an acf gallery field that displays multiple image ids or url paths to drive the slides within EasySlider? Alternatively, there is the repeater functionality, but I think that makes it far more complicated, unless I can wrap code around it to turn it into an EasySlider element.

    Thank you for any insight or help!
    -jason

    #1469290

    Hey Jason,

    Thank you for the inquiry.

    You may need to create another shortcode based on the Easy Slider element. Please try this in the functions.php file:

    function av_acf_slideshow_shortcode($atts) {
        $atts = shortcode_atts(array(
            'field' => 'av_acf_slideshow_ids',
        ), $atts, 'av_acf_slideshow');
    
        $slide_ids = get_field($atts['field']);
        $slide_ids_array = $slide_ids ? explode(',', $slide_ids) : [];
    
        if (empty($slide_ids_array)) {
            return 'No slides available.';
        }
    
        $slideshow = '[av_slideshow img_copyright="" size="featured" control_layout="av-control-default" slider_navigation="av-navigate-arrows av-navigate-dots" nav_visibility_desktop="" nav_arrow_color="" nav_arrow_bg_color="" nav_dots_color="" nav_dot_active_color="" img_copyright_font="" av-desktop-font-img_copyright_font="" av-medium-font-img_copyright_font="" av-small-font-img_copyright_font="" av-mini-font-img_copyright_font="" img_copyright_color="" img_copyright_bg="" animation="slide" transition_speed="" autoplay="false" interval="5" img_scale="" img_scale_end="10" img_scale_direction="" img_scale_duration="3" img_scale_opacity="1" conditional_play="" img_scrset="" lazy_loading="disabled" alb_description="" id="" custom_class="" template_class="" element_template="" one_element_template="" av_uid="av-m2ctangq" sc_version="1.0"]';
    
        foreach ($slide_ids_array as $slide_id) {
            $slideshow .= '[av_slide id="' . esc_attr(trim($slide_id)) . '" element_template="" title="" video=""][/av_slide]';
        }
    
        $slideshow .= '[/av_slideshow]';
    
        return do_shortcode($slideshow);
    }
    
    add_shortcode('av_acf_slideshow', 'av_acf_slideshow_shortcode');
    

    Create a repeater field with the ID av_acf_slideshow_ids, then add the IDs of the images that you’d like to display in the slideshow. You can use the shortcode [av_acf_slideshow] in a Code or Text Block element, and optionally specify a different ACF field by using [av_acf_slideshow field=”your_custom_field_name”].

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.