If you wish to have different Serene settings than those set on Portfolio → Full Screen in the theme options panel, you will need to set up a filter hook PHP function that will modify them when a specific page is loaded. To do this you will need the unique post / page ID. See the table below for available options and the examples below the table for how to use them. To find your post / page ID, edit the post in WordPress and look in the address bar. Amongst other things it will have a section that looks like post=702
, this
number is the post ID.
Key | Default | Description |
---|---|---|
speed | 2000 | Speed of the transition between background images in milliseconds |
transition | ‘fade’ | The transition animation. ‘none’, ‘fade’, ‘fadeOutFadeIn’, ‘slideDown’, ‘slideRight’, ‘slideUp’, ‘slideLeft’, ‘carouselRight’, ‘carouselLeft’ |
fitLandscape | false | Prevent landscape images from being cropped by locking them at 100% width |
fitPortrait | true | Prevent portrait images from being cropped by locking them at 100% height |
fitAlways | false | Prevent images from ever being cropped |
positionX | ‘center’ | Where to position the image on the X axis. ‘left’, ‘center’, ‘right’ |
positionY | ‘center’ | Where to position the image on the Y axis. ‘top’, ‘center’, ‘bottom’ |
easing | ‘swing’ | The easing function to use when transitioning |
controlSpeed | 500 | Speed that the controls fade in at, in full screen mode. |
slideshow | true | Enable the slideshow functionality (play/pause button) |
slideshowAuto | true | Start the slideshow automatically |
slideshowSpeed | 7000 | The time that each background image is displayed in the slideshow |
keyboard | true | Use the keyboard to control the background images. Left arrow = prev, right arrow = next, esc = close full screen mode |
captionPosition | ‘center bottom’ | The default caption position |
captionSpeed | 600 | The speed of the caption fade animation |
bullets | true | Turns on bullet navigation |
lowQuality | false | Turns on lower quality but higher performance transitions |
errorBackground | (empty string) | The path of the image to display if there is an error loading one of the images |
Examples
This code should be entered into the wp-content/themes/storm/functions.php file.
Change the options for a single post
Replace POSTID on line 1 of the code below with your post ID.
12
3
4
5
6
7
8
9
10
| add_filter('tcr_singular-post-POSTID_serene_options', 'storm_set_serene_options'); function storm_set_serene_options($options) { $options['speed'] = 4000; $options['slideshow'] = false; $options['lowQuality'] = true; return $options; } |
add_filter('tcr_singular-post-POSTID_serene_options', 'storm_set_serene_options'); function storm_set_serene_options($options) { $options['speed'] = 4000; $options['slideshow'] = false; $options['lowQuality'] = true; return $options; }
Change the options for a single page
Replace POSTID on line 1 of the code below with your page ID.
12
3
4
5
6
7
8
9
10
| add_filter('tcr_singular-page-POSTID_serene_options', 'storm_set_serene_options'); function storm_set_serene_options($options) { $options['speed'] = 4000; $options['slideshow'] = false; $options['lowQuality'] = true; return $options; } |
add_filter('tcr_singular-page-POSTID_serene_options', 'storm_set_serene_options'); function storm_set_serene_options($options) { $options['speed'] = 4000; $options['slideshow'] = false; $options['lowQuality'] = true; return $options; }
Change some options for all pages
This filter will only affect viewing single pages, any other page on your site such as single posts or archives will maintain your settings from the theme options panel.
1 2 3 4 5 6 7 8 9 10 | add_filter('tcr_singular-page_serene_options', 'storm_set_serene_options'); function storm_set_serene_options($options) { $options['speed'] = 8000; $options['slideshow'] = false; $options['bullets'] = false; return $options; } |
add_filter('tcr_singular-page_serene_options', 'storm_set_serene_options'); function storm_set_serene_options($options) { $options['speed'] = 8000; $options['slideshow'] = false; $options['bullets'] = false; return $options; }
Using multiple functions
PHP cannot have more than one function with the same name, if you try to use the same code to modify the settings for more than one page you will get a Fatal error. To avoid this you should change second parameter to add_filter
and the function name so that they are the same, but different to any existing function, for example:
12 34 5 6 7 8 9 10 11 1213 1415 16 17 18 19 20 21 | add_filter('tcr_singular-page_serene_options', 'storm_set_serene_options_page'); function storm_set_serene_options_page($options){ $options['speed'] = 8000; $options['slideshow'] = false; $options['bullets'] = false; return $options; } add_filter('tcr_singular-page-702_serene_options', 'storm_set_serene_options_702'); function storm_set_serene_options_702($options){ $options['speed'] = 4000; $options['slideshow'] = false; $options['lowQuality'] = true; return $options; } |
add_filter('tcr_singular-page_serene_options', 'storm_set_serene_options_page'); function storm_set_serene_options_page($options) { $options['speed'] = 8000; $options['slideshow'] = false; $options['bullets'] = false; return $options; } add_filter('tcr_singular-page-702_serene_options', 'storm_set_serene_options_702'); function storm_set_serene_options_702($options) { $options['speed'] = 4000; $options['slideshow'] = false; $options['lowQuality'] = true; return $options; }