Out of the box, the Genesis Responsive Slider can only be used in one way on your site because it’s options are set in an options panel. However, you can hook in to every setting, to create different sliders on different pages (although this code will not allow you to have different sized slideshows on every page – we’ll cover that in a future post).
I hook to the ‘wp’ action, because that is late enough for you to be able to calculate what slideshow parameters you may want, but early enough that the slideshow won’t have been generated yet. The parameters are changed by filtering genesis_pre_get_option_*, and a very useful PHP function called create_function.
[php]
add_action (‘wp’, ’emw_change_slide_show’);
function emw_change_slide_show() {
$slide_show_vars = array(
‘slideshow_timer’ => 8000,
‘slideshow_delay’ => 1500,
‘slideshow_arrows’ => 1,
‘slideshow_pager’ => 0,
‘slideshow_loop’ => 1,
‘slideshow_height’ => 250,
‘slideshow_width’ => 978,
‘slideshow_effect’ => ‘fade’,
‘slideshow_title_show’ => 1,
‘slideshow_excerpt_show’ => 0,
‘slideshow_excerpt_width’ => 30,
‘location_vertical’ => ‘bottom’,
‘location_horizontal’ => ‘right’,
‘slideshow_hide_mobile’ => 1,
‘include_exclude’ => ‘include’,
‘post_type’ => ‘page’,
‘post_id’ => ‘4, 7, 9’
);
foreach ($slide_show_vars as $option => $value)
add_filter ("genesis_pre_get_option_{$option}", create_function (”, "return ‘{$value}’;"));
[/php]
If you want to change the size of the slideshow, as we’ve done for this example, you’ll need a few additional lines (and you’ll need to re-generate WordPress thumbnails after you’ve made the change). Although the code on this page allows you to change the size of the slideshow from the default, you’ll need to have the same size on every page:
[php]
add_action (‘wp’, ’emw_change_slider_image_size’);
function emw_change_slider_image_size() {
add_image_size (‘slider’, 978, 250, true);
}
[/php]
Finally, if you want to remove the Responsive Slider menu from the admin (because those settings are now overridden):
[php]
add_action (‘init’, ’emw_remove_responsive_slider_menu’);
function emw_remove_responsive_slider_menu() {
if (is_admin())
remove_action(‘admin_menu’, ‘genesis_responsive_slider_settings_init’, 15);
}
[/php]
Leave a Reply