Support

Account

Forum Replies Created

  • // Add Script to admin
    function add_acf_wysiwyg_default_value()
    {
    ?>
        <script type="text/javascript">
            var elementID = 'Your acf div id';
            var defaultValue = '<style>.style-1 { color: red; }</style><div class="style-1">Default Value....</div>';
    
            window.onload = async function() {
                if (document.querySelector('#' + elementID)) {
                    if (document.querySelector('#' + elementID).innerHTML == '') {
                        await document.getElementById('' + elementID + '-html').click();
                        document.querySelector('#' + elementID).innerHTML = defaultValue;
                        document.getElementById('' + elementID + '-tmce').click();
                    }
                }
            }
        </script>
    <?php
    }
    add_action('admin_footer', 'add_acf_wysiwyg_default_value');
Viewing 1 post (of 1 total)