-
AuthorPosts
-
February 2, 2019 at 7:46 pm #1062045
Hey,
i am using currently the layerslider option but the Issue is it does not work like intend. I have a location slider with 4 slides in total. I want one specific slide for a specific weekday
Friday – Monday -> Slide 1
Tuesday -> Slide 2
Wedneyday – Slide 3
Thursday -> Slide 4Maybe someone have an idea to realise this with some kind of JS? I am out of ideas now.
February 4, 2019 at 8:28 am #1062517Hey cr3epy,
You might be able to get an automated script to do that for you, but we can’t help out with that since it would be considered custom work.
Best regards,
RikardFebruary 4, 2019 at 10:20 am #1062568Please be a little more specific about your requirements.
For example, would it be enough if you had a color section that changes the wallpaper day by day?if so : make a color-section and define one background-image as you like to have it ( cover image , bottom center etc. pp)
Give a unique ID to the color-section f.e.: customID
you have to know now the page id ( so that we don’t have to load the script on pages that don’t need it at all. ) (in my case it is page id 34024)
– the relative path to your images (imglocation)
Put this into your child-theme functions.phpadd_action( 'wp_footer', 'schedule_bg_image' ); function schedule_bg_image() { if(is_page(34024)){ ?> <script type="text/javascript"> var imglocation = "/wp-content/uploads/layerslider/Origami/"; function ImageArray (n) { this.length = n; for (var i =1; i <= n; i++) { this[i] = ' ' } } image = new ImageArray(7); image[0] = 'slide1.jpg'; // Sunday image[1] = 'slide1.jpg'; // Monday image[2] = 'slide2.jpg'; // Tuesday image[3] = 'slide3.jpg'; // Wednesday image[4] = 'slide4.jpg'; // Thursday image[5] = 'slide1.jpg'; // Friday image[6] = 'slide1.jpg'; // Saturday var currentdate = new Date(); var imagenumber = currentdate.getDay(); document.getElementById('customID').style.backgroundImage = 'url(' + imglocation + image[imagenumber] + ')'; </script> <?php } }
see here : https://webers-testseite.de/bg-scheduling/
February 4, 2019 at 2:35 pm #1062689Hi,
Thank you @Guenni for sharing the solution.
Let us know if this worked for you or you need further assistance.
Thank you for using Enfold.
Best regards,
VinayFebruary 6, 2019 at 2:32 pm #1063633Thank you Guenni007 – i will try this when i find some time the solution could work i think. I will comeback as soon as i tested it. Sorry for the delay for some reasons i didnt get the email notification.
February 14, 2019 at 12:14 pm #1066922Hey Guenni007,
i added this now into my theme and i receive.
Uncaught TypeError: Cannot read property ‘style’ of null
at (index):349February 16, 2019 at 12:59 pm #1067690first of all : have you adjusted the code to your settings:
The main thing for that error seams to be that you have forgotten the customID to set – because if that DOM Element does not exist – it is impossible to style it !!!
document.getElementById('customID') etc …
f.e. :- have you done this (see comment above) : Give a unique ID to the color-section f.e.: customID – or what ever you like – but then it has to be synchronized with the script line mentioned above
- the code above is ment for child-theme functions.php – is that the place where you put in that code
- adjust the url line to define the place where the images are in:
var imglocation = "/wp-content/uploads/layerslider/Origami/";
- the code above is for my installation. I don’t want to load it everywhere so i surrounded it by an if-clause concerning to my page-id.
have you changed it to your page:if(is_page(34024)){
-
AuthorPosts
- You must be logged in to reply to this topic.