Skip to main content
Login Join
Snippet · PHP

Customize ACF WYSIWYG Editor Block Formats

Shared by Sumit Javia | Senior WordPress Developer · May 25, 2026 · @acf/fields/wysiwyg/toolbars/mce_init

46 views
Back to Snippets

This snippet customizes the available block format options in the Advanced Custom Fields (ACF) WYSIWYG editor toolbar. It adds support for headings, preformatted text, and a custom “Paragraph Big” style for improved content formatting control.

/**
 * Customize block format options in the ACF WYSIWYG editor.
 *
 * This snippet modifies the TinyMCE block format dropdown
 * for Advanced Custom Fields (ACF) WYSIWYG editors by adding
 * custom heading, paragraph, and preformatted text options.
 *
 * Added Formats:
 * - Paragraph
 * - Heading 1–6
 * - Preformatted
 * - Paragraph Big (custom class: p-big)
 *
 */
function sj_customize_acf_wysiwyg_formats( $mce_init, $editor_id ) {

    // Define custom block format options.
    $block_formats = '
        Paragraph=p;
        Heading 1=h1;
        Heading 2=h2;
        Heading 3=h3;
        Heading 4=h4;
        Heading 5=h5;
        Heading 6=h6;
        Preformatted=pre;
        Paragraph Big=p.p-big
    ';

    // Apply custom block formats to the editor.
    $mce_init['block_formats'] = $block_formats;

    return $mce_init;
}

add_filter( 'acf/fields/wysiwyg/toolbars/mce_init', 'sj_customize_acf_wysiwyg_formats', 10, 2 );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments