Snippets: Add New Formats Under the Total Styles in the Text Editor

If you want to create a custom style you can apply to text, buttons or lists while writing blog posts it's a good idea to insert this into the Formats dropdown for easy access. This snippet shows you how you can add more options under the Total Styles tab for quick use.

add_filter( 'wpex_tiny_mce_formats_items', function( $items ) {
	$items[] = array(
		'title'   => esc_html__( 'Your New Item', 'total' ),
		'inline'  => 'span', // Tag to be added to item (p, a, span, ul)
		'classes' => 'your-custom-class', // The class that is added for styling
	);
	return $items;
} );

Result:

Snippet Type: PHP

Posted Under: Other

All PHP snippets should be added via a child theme's functions.php file.