3

I am using WordPress’ latest custom video header feature. Anybody has an idea how to stop autoplay? Checked filters but did not find a way to disable autoplay.

/wp-includes/js/wp-custom-header.js has the default settings. However not getting any clue how I may override it without editing core files 😉

1 Answer 1

3

I don't think there is a need to override any core files. You can just use javascript to stop autoplaying the video.

I tested the following code on Twenty Seventeen theme and it works fine. For example:

$( document ).ready( function() {
    $( document ).on( 'wp-custom-header-video-loaded', function() {
        $("#wp-custom-header-video").attr('autoplay',false);
    });
});

This does the trick.

1
  • That works thanks. The thing is I was trying same snippet in Twenty Seventeen theme's global.js file. Apparently... I did not notice that I was placing it outside of document.ready and hence it was not working. Thank you very much. Commented Jan 28, 2017 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.