Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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 4

    Maybe someone have an idea to realise this with some kind of JS? I am out of ideas now.

    #1062517

    Hey 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,
    Rikard

    #1062568

    Please 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.php

    add_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/

    #1062689

    Hi,

    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,
    Vinay

    #1063633

    Thank 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.

    #1066922

    Hey Guenni007,

    i added this now into my theme and i receive.

    Uncaught TypeError: Cannot read property ‘style’ of null
    at (index):349

    #1067690

    first 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)){
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.