I'm working on a custom meta box and i am trying to limit the Block format tag to just P, H3 and H4 tags, i did it this way and not sure why it doesn't display the block format dropdown;

wp_editor( $content, 'fm_display_callback', array (
    'media_buttons' => false,
    'textarea_rows' => 5,
    'quicktags' => array( 
        'buttons' => 'strong,em,del,ul,ol,li,close' 
    'tinymce'       => array(
        'toolbar1'      => 'bold,italic,underline,bullist,numlist,alignleft,forecolor,aligncenter,alignright,link,unlink,undo,redo',
        'toolbar2'      => '',
        'toolbar3'      => '',
        'block_formats' => "Paragraph=p; Heading 3=h3; Heading 4=h4",
) );

as listed on WordPress Codex, it doesnt work for some reason. I have as well tried making the block_formats key into an array like this;

 'block_formats' => array(
      'Heading 3=h3',
      'Heading 4=h4',

and like this;

 'block_formats' => array(
      'Paragraph' => 'p',
      'Heading 3' => 'h3',
      'Heading 4' => 'h4',

Not sure what i'm missing that is preventing the block format to display, as this is what i get visually (No dropdown)

enter image description here


You need to add formatselect in one of the toolbars, and WordPress by default have it in toolbar1:

wp_editor( $content, 'fm_display_callback', array(
    'tinymce' => array(
        'toolbar1' => 'formatselect,bold,italic,...',
) );

Check this and https://www.tiny.cloud/docs-4x/configure/content-formatting/#block_formats.

  • 1
    This took me three hours to find. Thank you Thank you! Oct 29 '20 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.