Skip to content

Instantly share code, notes, and snippets.

function metaslider_title_attribute($attributes, $slide, $slider_id) {
if (!strlen($attributes['alt'])) {
$attributes['alt'] = get_the_title($slide['id']);
}
return $attributes;
}
add_filter('metaslider_flex_slider_image_attributes', 'metaslider_title_attribute', 10, 3);
add_filter('metaslider_flex_slider_image_attributes', 'metaslider_nopin', 10, 3);
function metaslider_nopin($attributes, $slide, $slider_id) {
$attributes['nopin'] = "nopin";
return $attributes;
}
@media screen and (max-width: 480px) {
.metaslider .caption-wrap {
display: none;
}
}
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* This code will display a counter in the form of "X / Y" (where X is the current slide and Y is the total number of slides) below the slideshow.
*/
function metaslider_add_counter_div($options, $slider_id, $settings) {
$options['start'][] = "
var container = $('<div />').addClass('counter_{$slider_id}').css({
'text-align' : 'center',
/**
* Output the slideshow to the 'after_header' section of the theme
*/
add_action('genesis_after_header', 'metaslider_homepage_slider', 10, 1);
function metaslider_homepage_slider() {
if (is_front_page()) {
echo do_shortcode("[metaslider id=123 percentwidth=100]"); // replace 123 with your slidehsow ID
}
}
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* Don't pause the slideshow when interacting with control elements.
*/
function metaslider_flex_disable_pause_on_action($options, $slider_id, $settings) {
$options['pauseOnAction'] = 'false';
return $options;
}
add_filter('metaslider_flex_slider_parameters', 'metaslider_flex_disable_pause_on_action', 11, 3);
/**
* INSTALLATION: this code should be pasted into your theme's functions.php file.
*
* USAGE:
* Install 'WP Video Lightbox'.
* Add an image slide to your Meta Slider slideshow and enter a YouTube or Vimeo URL into the URL field.
*
* eg: http://vimeo.com/29417470?width=800&height=450
* http://www.youtube.com/watch?v=G7z74BvLWUg&width=640&height=480
*/
function metaslider_flex_js($javascript, $slider_id) {
$javascript .= "$('.video1').click(function () {
$('#metaslider_{$slider_id}').flexslider(0); // switch to the first slide
});
$('.video2').click(function () {
$('#metaslider_{$slider_id}').flexslider(1); // switch to the second slide
});
}
return $javascript;