Code To Add Button for Horizontal Line in TinyMCE Editor

WordPress uses TinyMCE editor which is good as this means you don’t have to write any single HTML code to write up your post. TinyMCE allows you to write your posts as easy as using Microsoft Word.

The default TinyMCE comes with very basic feature and shockingly there’s no button to add horizontal line in your post. Sometimes you might need to use horizontal line in your post to separate it into few segments.

Horizontal line

See that horizontal line separating those two paragraphs?

You can add the line using Ā tag. However, I feel more convenience to add the button to add that horizontal line so every time I want to add a horizontal line, I can simply click on the button.

To add the button for the horizontal line, paste the following snippet in your functions.php file or even better your functionality plugin:

function afn_more_buttons($buttons) {
$buttons[] = ‘hr’;
return $buttons;
add_filter(“mce_buttons”, “afn_more_buttons”);