Skip to content

Instantly share code, notes, and snippets.

@nfsarmento
Last active December 11, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfsarmento/44675ae7053e86779c254c8813496775 to your computer and use it in GitHub Desktop.
Save nfsarmento/44675ae7053e86779c254c8813496775 to your computer and use it in GitHub Desktop.
Slick Slider ACF/Options shortcode
// ACF options
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
}
// Slick Slider Shortcode
function slick_slider_shortcode () {
ob_start();
?>
<?php if( have_rows('clients_slider', 'option') ): ?>
<div class="slider-name js-footer-slider">
<?php while ( have_rows('clients_slider', 'option') ) : the_row(); ?>
<div class="slider-container">
<a class="slider__url" href="<?php the_sub_field('slider_url');?>">
<img class="image-slider" src="<?php the_sub_field('slider_image');?>" alt="genium">
</a>
</div>
<?php endwhile; ?>
</div>
<style media="screen">
.slick-slide img{
width: 100%;
}
</style>
<?php endif; ?>
<?php
return ob_get_clean();
}
add_shortcode('clientsliders', 'slick_slider_shortcode');
// Slick Slider Script
jQuery(document).ready( function(){
$(".js-footer-slider").slick({
infinite: !0,
slidesToShow: 7,
dots: !1,
arrows: !1,
autoplay: !0,
autoplaySpeed: 1e3,
speed: 1e3,
responsive: [{
breakpoint: 782,
settings: {
slidesToShow: 3
}
}, {
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
infinite: true
}
}]
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment