Hi, wouldn’t be cool displaying a different slider on the front page, depending on the season?
That’s what you have to do:
- Create 4 sliders and name with the season’s names (lowercase)
- In Appearance -> Customize -> Content: home, posts, .. -> Front Page -> Slider Options
Select a front page slider. You can use the demo slider, or whatever, but select one 😉 - In your child-theme functions.php add this snippet:
function get_season() { $season_slider = array('/12/21'=>'winter', '/09/21'=>'autumn', '/06/21'=>'summer', '/03/21'=>'spring', '/01/01'=>'winter' ); //this needed to be at Jan 1st foreach ($season_slider as $key => $value) { // Loop through the season dates $season_date = date("Y").$key; if (strtotime("now") > strtotime($season_date)) // If we're after the date of the starting season return $value; } } add_filter('tc_slider_name_id', 'season_sliders'); function season_sliders($slider_name_id){ $sliders = tc__f('__get_option' , 'tc_sliders'); // if there isn't a slider with a season name fallback on the home slider if ( tc__f('__is_home') && isset( $sliders[get_season()] ) ) return get_season(); return $slider_name_id; }
Where to copy/paste this code?
Add it to your child-theme functions.php.
Everything you need to know about creating a child theme with Customizr here.
Goodbye and goodluck
12 thoughts on “Make the Customizr home slider season based”
How would I adapt this code to display a seasonal header image, rather than a slider?
Hi,
The developer team handles support for Customizr at https://wordpress.org/support/theme/customizr and for Customizr-Pro at http://presscustomizr.com/support/. Please post your query there with a link to your site.
Hi
I need help.
I want to have another slider in other widths (for example, the first slider 320 px, 320px-960px second slider, etc.). I did not find this on any page.
I speak Polish, English I know a little bit-sorry 🙁
Hello
I want to know, if there is any code or method to bring shady effect in page when image is selected for preview in gallery??
I mean as it happens in picasa??? main focus on selected image only and rest of the background go black??
Hey Nic
I have a problem. First of all, I’m speaking from Brazil, and my english is not so good, so I can’t even say if my problem can be resolved in this page. But I looked everywhere and I didn’t find anything.
I just want to put a link on the image of the slider. It is possible to do that? In all the area of the image.
I saw that the link can go in the butom that we create. But I didn’t want do put this buttom in front of my image. I’d like to get my image linked to the page.
I undestand something of HTML codes. But I can’t find where the code of the slider is.
So I need some help. Thank you.
Mayara Samways
Hi Mayara,
you can find the snippets your looking for here:
http://presscustomizr.com/snippet/linking-the-whole-slides-picture-to-a-pagepost-in-customizr/
http://presscustomizr.com/snippet/setting-a-custom-external-url-to-a-slide/
then you can hide the slider’s buttons with this css : `#customizr-slider .btn {display: none;}`
You’re welcome.
If you happen to know which plugin could cause that, let me know 😉
Page cache successfully emptied – seems to work fine now. Thank you
This in your page.
` Served from: honeybunny.ro @ 2015-03-09 11:09:52 by W3 Total Cache –>`
So I think you’re viewing a cached page. Can you delete the total cache cache?
Hope this helps.
Hi
I dont use the code.
After I disable the loading icon the slide appers but only if I see the page as admin.
Hi Vlad,
do you use the code above?
Anyway, actually the slides are there, for some reason the loading icon isn’t hidden ..
Could it be due to a conflicting plugin, but you can also disable the loading icon in Global Settings -> Images
Hope this helps
Hi
Do you know why after the 3.3.8 update my front page slider won’t load anymore ?
Thank you