Home / functions.php / Add horizontal rule button to editor
  • How to Add horizontal rule button to editor


    Adding this PHP snippet to the functions.php of your wordpress theme will add a <hr /> button to the editor.

    ( click code to copy )

    wordpress snippet : PHP

    function enable_more_buttons($buttons) {
      $buttons[] = 'hr';
     return $buttons;
    add_filter("mce_buttons", "enable_more_buttons");

    ( WordPress codex functions, hooks, in this snippet. )

  • Excellent!

  • Useful!

  • Pingback: Add horizontal line button to Wordpress’s editor | The Real Lance Brown()

  • Yagoob Amani

    Great! Thanks for sharing.

  • 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?

    • 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.

      • 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….

        • 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.


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

  • Simon Codrington

    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!

  • Iced_dump

    thank you for the quick code..

  • thanks!

  • Falle

    Brilliant! Been looking for this for a while!