At the end of every project I do a one-to-one client training session where apart from showing my client how to use their new website, I also point out a few gotcha’s people often fall into.
One of them is:
You see that Heading 1 style in the visual editor format drop-down box? Well don’t use it!
And I go on to explain that ideally, you should only have one Heading 1 on a page and your Genesis theme makes the title of your page a heading 1. You can use as many heading 2, heading 3, etc as makes sense on your page.
After giving one such tutorial yesterday, I set about figuring out how to remove that Heading 1 from the visual editor format drop-down box. And it turns out to be fairly straightforward.
The code below goes in your functions file, or you can make it into a plugin if you prefer.
As always do ensure you have a backup of your functions file before you make any changes.
It is not strictly true that this removes Heading 1. What it does is add all the styles except the heading 1. And for good measure, I move the mostly unused Address and Pre formats to the end of the list.
This little snippet will be going in all my future themes, and I can cut out that 5-minute section of my tutorial. Result.
You can also view this code on github.
add_filter('tiny_mce_before_init', 'tiny_mce_remove_unused_formats' );
/*
* Modify TinyMCE editor to remove H1.
*/
function tiny_mce_remove_unused_formats($init) {
// Add block format elements you want to show in dropdown
$init['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Pre=pre';
return $init;
}
Slimypants
Genius, I’ve been looking for this for so long!
DrLightman
Thanks!
Andre
Cool, pretty nice trick! Thanks for sharing it Jo! 🙂