/** * Displays the slider for the homepage */ public function render_homepage_slider() { $slider = new BlizzardWatchSlider(); if (have_rows('slides', 'option')) { while (have_rows('slides', 'option')) { the_row(); $post = get_sub_field('post'); $text = get_sub_field('text_override'); $image = get_sub_field('image_override'); $link = get_permalink($post->ID); if (!$text) { $text = $post->post_title; } if (!$image) { $image = get_the_post_thumbnail_url($post->ID); } $slider->add_slide($image, $text, $link); } } $slider->render_slider(); }
$("#bw-slider-div").slick({ slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, dots: false, infinite: true, speed: 500, fade: true, arrows: true, prevArrow: "<a class=\\"slick-prev slider-slick-prev\\" style=\\"display: inline; position: absolute; left: 0; top: 40%; z-index: 100; color: white; font-size: 25px; margin-left: 5px; font-family: times; cursor: pointer;\\"><</a>", nextArrow: "<a class=\\"slick-next slider-slick-next\\" style=\\"display: inline; position: absolute; right: 0; top: 40%; z-index: 100; color: white; font-size: 25px; margin-right: 10px; font-family: times; cursor: pointer;\\">></a>", cssEase: "linear" }); }); </script>'; $content .= '<div class="bw-slider-container"><div id="bw-slider-div">'; foreach ($this->slides as $slide) { $content .= '<div style="position: relative;">'; $content .= '<a href="' . $slide['link'] . '">'; $content .= '<img class="img-responsive" src="' . $slide['image'] . '" style="width: 100%;" />'; $content .= '<div style="position: absolute; bottom: 0px; left: 0px; width: 100%; background: rgba(0,0,0,0.7); opacity: 1; font-family: Lato, sans-serif !important; font-weight: 400 !important; font-size: 22px; line-height: 1.1em; padding: 5px 10px; color: white;">' . $slide['text'] . '</div>'; $content .= '</a>'; $content .= '</div>'; } $content .= '</div></div>'; return $content; } } BlizzardWatchSlider::enque_scripts();