Tagged: acf, easyslider, Images
-
AuthorPosts
-
October 16, 2024 at 10:28 pm #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!
-jasonOctober 17, 2024 at 6:59 am #1469290Hey 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,
IsmaelOctober 28, 2024 at 5:56 pm #1470030Good day all!
I got to play around with this briefly a week or so ago, but was not able to get it working and after trying a few different things, am still not getting it to work properly.
I kept getting No slides available, the response if it does not get a slideshow id. After messing around with pulling other parameters, I noticed it would pull the number 3 when I queries using dynamic data for the “av_acf_slideshow_ids” which happens to be the number of slides I have assigned to that records repeater field. So, I think we are really close to it working, but my attempts to adjust it did not work. So, I am hoping you might take a quick look at it (link and creds provided below).
-jason
October 28, 2024 at 5:58 pm #1470031Oops, forgot to include more information that would help getting to it. (below)
October 31, 2024 at 6:37 am #1470328Hi,
Thank you for the update.
We received this Wordfence error when we try to access the site:
Your access to this site has been limited by the site owner
Your access to this service has been limited. (HTTP response code 503)If you think you have been blocked in error, contact the owner of this site for assistance.
Please disable the plugin temporarily.
Best regards,
IsmaelNovember 1, 2024 at 5:53 pm #1470443This reply has been marked as private.November 4, 2024 at 4:25 am #1470526Hi,
I noticed it would pull the number 3 when I queries using dynamic data for the “av_acf_slideshow_ids” which happens to be the number of slides I have assigned to that records repeater field.
Did you use the IDs of the images in an array as the value for the av_acf_slideshow_ids field? When you try to debug the code, what is the value of
$slide_ids
? This should be an array containing the IDs of the images that you’d like to use in the slider.Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.