Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Modify the available block formats within WordPress' TinyMCE editor. A quick solution for https://twitter.com/cdils/status/970854979735977984
<?php
/**
* Change the block formats available in TinyMCE.
*
* @link http://codex.wordpress.org/TinyMCE_Custom_Styles
*
* @param array $init Default settings to be overridden.
*
* @return array The modified $init array.
*/
function cdils_change_mce_block_formats( $init ) {
$block_formats = array(
'Paragraph=p',
'Heading 1=h1',
'Heading 2=h2',
'Heading 3=h3',
'Heading 4=h4',
'Heading 5=h5',
'Heading 6=h6',
'Preformatted=pre',
'Code=code',
);
$init['block_formats'] = implode( ';', $block_formats );
return $init;
}
add_filter( 'tiny_mce_before_init', 'cdils_change_mce_block_formats' );
@cdils

This comment has been minimized.

Show comment Hide comment
@cdils

cdils Mar 6, 2018

❤️

cdils commented Mar 6, 2018

❤️

@stevegrunwell

This comment has been minimized.

Show comment Hide comment
@stevegrunwell

stevegrunwell Mar 6, 2018

Hey Bart, remember this Gist? Well it's back...in blog form! https://stevegrunwell.com/blog/wordpress-tinymce-block-formats/

Owner

stevegrunwell commented Mar 6, 2018

Hey Bart, remember this Gist? Well it's back...in blog form! https://stevegrunwell.com/blog/wordpress-tinymce-block-formats/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment