• Hi there! When I put anything in functions file in child theme and save changes my site collapses!? Bug oor?! I am using 2.1.2. version of theme.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Not sure what you mean by “anything”, what exactly are you trying?

    Thread Starter bozonja

    (@bozonja)

    Any random code that I want to change and put in functions.php in child theme.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You can’t put random code into functions.php, it’s PHP and you have to use PHP syntax. There are other reasons why it could break, but we’d need to see the code you’re using.

    Thread Starter bozonja

    (@bozonja)

    I have putted this:

    `<script type=”text/javascript”>
    // Check if first slider image is loaded, and load flexslider on document ready
    jQuery(document).ready(function(){
    var firstImage = jQuery(‘#flexslider-featured’).find(‘img’).filter(‘:first’),
    checkforloaded = setInterval(function() {
    var image = firstImage.get(0);
    if (image.complete || image.readyState == ‘complete’ || image.readyState == 4) {
    clearInterval(checkforloaded);

    jQuery(‘#flexslider-featured’).flexslider({
    animation: “slide”,
    useCSS: false, // Fix iPad flickering issue
    slideshow: true,
    directionNav: true,
    controlNav: true,
    pauseOnHover: true,
    slideshowSpeed: 4000,
    animationSpeed: 400,
    smoothHeight: true,
    touch: false
    });

    }
    }, 20);
    });
    </script>`

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Yeah that’s JavaScript and not PHP, so that will break your site.

    Thread Starter bozonja

    (@bozonja)

    So this can´t go in functions.php in child theme? How can I edit this in child theme? I must create another stylesheet and put it in child theme folder oor?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Try putting your JavaScript into a ‘.js’ file, just this bit:

    // Check if first slider image is loaded, and load flexslider on document ready
    jQuery(document).ready(function(){
    var firstImage = jQuery('#flexslider-featured').find('img').filter(':first'),
    checkforloaded = setInterval(function() {
    var image = firstImage.get(0);
    if (image.complete || image.readyState == 'complete' || image.readyState == 4) {
    clearInterval(checkforloaded);
    
    jQuery('#flexslider-featured').flexslider({
    animation: "slide",
    useCSS: false, // Fix iPad flickering issue
    slideshow: true,
    directionNav: true,
    controlNav: true,
    pauseOnHover: true,
    slideshowSpeed: 4000,
    animationSpeed: 400,
    smoothHeight: true,
    touch: false
    });
    
    }
    }, 20);
    });

    And then enqueue that ‘.js’ file through your Child Theme functions.php file: http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Child theme functions bug’ is closed to new replies.