By default font selector is hidden. If you want to show WordPress font selector in text editor all you need to do is add the following code snippet to your theme’s function.php
file.
Feel free to replace PREFIX_
with your theme name or any 3 character custom string, as long as it’s unique, could be your initials. alm_
.
<?php
// Create a function that adds the font selector
if ( ! function_exists( 'PREFIX_mce_buttons' ) ) {
function PREFIX_mce_buttons( $buttons ) {
array_unshift( $buttons, 'fontsizeselect' ); // Add Font Size Select
return $buttons;
}
}
// Hook the function the mce buttons event
add_filter( 'mce_buttons_2', 'PREFIX_mce_buttons' );
// Everything that follows is OTIONAL ---
// The following is only if you want to customize the default font sizes
// Create a function to Customize mce editor font sizes
if ( ! function_exists( 'PREFIX_mce_text_sizes' ) ) {
function PREFIX_mce_text_sizes( $initArray ){
$initArray['fontsize_formats'] = "9px 10px 12px 13px 14px 16px 18px 21px 24px 28px 32px 36px 40px";
return $initArray;
}
}
// Hook the function in the mce before init event
add_filter( 'tiny_mce_before_init', 'PREFIX_mce_text_sizes' );
Like the page is you found this useful! Cheers!