Skip to content

Instantly share code, notes, and snippets.

/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* - Enable CSS transitions for Flex Slider.
* - Fixes some issues with mobile browsers (slides go white after first complete rotation of slides)
*
* Compatibility: Flex Slider.
*/
function metaslider_flex_use_css($options, $slider_id, $settings) {
$options['useCSS'] = "true";
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* This code will convert the list of tabs into an ordered drop down menu. Ideal if you have lots of slideshows set up!
*/
function metaslider_max_tabs() {
return 5; // specify the number of tabs you want to see before converting to a dropdown
}
add_filter('metaslider_max_tabs', 'metaslider_max_tabs');
<?php
if (is_page() == 123) {
echo do_shortcode("[metaslider id=XXX]"); // Slideshow to show on page ID 123
}
else if (is_page() == 456) {
echo do_shortcode("[metaslider id=XXX]"); // Slideshow to show on page ID 456
}
else if (is_page() == 789) {
echo do_shortcode("[metaslider id=XXX]"); // Slideshow to show on page ID 789
}
/*
Vantage Theme, remove max width/layer centering.
Usage: Copy and paste this code into your themes style.css file.
*/
body.responsive.layout-full #page-wrapper .metaslider .full-container,
.layout-full #page-wrapper .metaslider .full-container {
max-width: none;
}
/*
Always show arrows (Flex Slider)
Usage: Copy and paste this code into your themes style.css file
*/
.metaslider .flex-direction-nav .flex-prev {
opacity: 1;
left: 5px;
}
.metaslider .flex-direction-nav .flex-next {
opacity: 1;
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* Use this filter to stop Flex Slider from looping back to the start of the slideshow (ending on the last slide)
*/
function metaslider_loop_once($options, $slider_id, $settings) {
$options['after'][] = "if ((slider.currentSlide + 1) == slider.count) { slider.pause(); }";
return $options;
}
add_filter('metaslider_flex_slider_parameters', 'metaslider_loop_once', 10, 3);
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* Use this filter to stop Flex Slider from looping back to the start of the slideshow (ending on the first slide, after a complete rotation)
*/
function metaslider_loop_once_stop_on_first($options, $slider_id, $settings) {
$options['after'][] = "if (slider.currentSlide == 0) { slider.pause(); }" ;
return $options;
}
add_filter('metaslider_flex_slider_parameters', 'metaslider_loop_once_stop_on_first', 10, 3);
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* Use this filter to set a custom delay on the first slide in the slideshow.
*/
function metaslider_delay_first_slide($options, $slider_id, $settings) {
$delay = 5000; // delay for first slide in milliseconds
$options['start'][] = "slider.pause(); setTimeout(function(){ slider.play(); }, {$delay});" ;
$options['after'][] = "if (slider.currentSlide == 0) { slider.pause(); setTimeout(function(){ slider.play(); }, {$delay}); }" ;
return $options;