How to Add Horizontal Rule Button to Editor in WordPress

Snippets by IsItWP

Are you looking for a way to add a <hr /> button to the editor? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add horizontal rule button to editor in WordPress.


All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function enable_more_buttons($buttons) {
  $buttons[] = 'hr';
 return $buttons;

add_filter("mce_buttons", "enable_more_buttons");

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 9 best WordPress real estate plugins and how to set up Google Analytics eCommerce tracking for WooCommerce.

Comments   Leave a Reply

  1. Brilliant! Been looking for this for a while!

  2. thanks!

  3. thank you for the quick code..

  4. Simon Codrington March 27, 2012 at 6:18 pm

    Hey thanks for the quick code, it appeared near first on Google for my search result and was exactly what I needed. I’m still kinda amazed WordPress even in version 3 doesn’t have the HR element as a button in TinyMCE.. Weird. 

    Thanks again!

  5. color me dumb, but add the snippet WHERE in the functions.php file (which, by my count is four thousand five hundred and fifty-four lines long)?
    I put this snippet at the very bottom of the functions.php file and got a fatal error crash…any ideas?

    1. Hi Ken,
      I posted the code sample http://pastebin.com/nkk6bZ8B
      Keep in mind if you have any line breaks after the last ? > it will cause an error make sure no space after the last ? >. however the location does not matter. If you continue to get errors post the code into pastebin.com and ill check things out if you still have problems.

      1. thanks- I really do appreciate your efforts and the reply but its just not working for my theme, and I still know how to type an “h” and an “r” hehehehehehe.

        Thanks anyway, maybe someday WordPress will include this feature in an update….

        1. This is not so much a wordpress option as a TinyMCE option, if you wanted to post your functions.php file within the pastebin.com website I can take a look and fix the problem for you. Just paste the code and reply with the URL and ill check things out. If you don’t want to post publicly you can use the wpsnipp contact form.


        2. Hi Ken,
          It does not appear that this is the whole file however if it is I fixed the problem.

  6. Great! Thanks for sharing.

    1. np glad you like the snippet.

  7. Add horizontal line button to Wordpress’s editor | The Real Lance Brown March 5, 2011 at 3:19 am

    […] has provided a little snippet of code that will add a “horizontal rule” (or <hr />) button to the default editor in […]

  8. lorenzocoffee© L V February 25, 2011 at 2:59 pm


    1. yes the other things you could do is create a few shortcodes to drop in html elements you need. Check out this snippet.

  9. Pippin Williamson February 25, 2011 at 2:48 pm


    1. thanks pippin

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!