Browse: Home / Snippets /

Collapse Focus Mode sidebar on window load

Contents


Snippet #

add_action( 'wp_footer', function() {
    ?>
    <script>
    jQuery(document).ready(function($) {
        $('.learndash-wrapper .ld-focus').addClass('ld-focus-sidebar-collapsed');
    });
    </script>
    <?php
}, 999 );

// Target specific browser sizes

add_action( 'wp_footer', function() {
    ?>
    <script>
        // You can specify and target specific device ranges below.
        if (jQuery(window).width() >= 640 && jQuery(window).width() <= 1024) {
            jQuery(document).ready(function($) {
                $('.learndash-wrapper .ld-focus').addClass('ld-focus-sidebar-collapsed');
            });
        }
    </script>
    <?php
}, 999 );