Remove buttons from a WYSIWYG editor for a specific ACF field type

You can pretty easily customize the advanced custom fields WYSIWYG toolbars globally, however doing so on a case-by-case basis needs to be done in JS since the editing experience is so dynamic.

This code is looking for a specific ACF field called step_text and sets the WYSIWYG editor to only allow bold, italic and links.

    static function () {
        <script type="text/javascript">
            (function ( $ ) {

                        function( mceInit, id, field ) {
                            if ( field.context.dataset.hasOwnProperty( 'type' ) && field.context.dataset.hasOwnProperty( 'name' ) && 'step_text' === && 'wysiwyg' === field.context.dataset.type ) {
                                mceInit.toolbar1 = 'bold,italic,link';
                            return mceInit;

            )( jQuery );

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.