Skip to content

Snippet: Add New Options Under the Editor “Formats” Button

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;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top