wordpress snippets last updated   : April 14, 2014
we now have 629 snippets

Add horizontal rule button to editor

wordpress snippet

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

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

  • http://twitter.com/pippinspages Pippin Williamson

    Excellent!

    • http://wpsnipp.com Kevin Chard

      thanks pippin

  • http://twitter.com/lorenzocoffee lorenzocoffee© L V

    Useful!

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

  • Yagoob Amani

    Great! Thanks for sharing.

    • http://wpsnipp.com Kevin Chard

      np glad you like the snippet.

  • http://profiles.google.com/mrkenray Ken Ray

    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?

    • http://wpsnipp.com Kevin Chard

      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.

      • http://profiles.google.com/mrkenray Ken Ray

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

        • http://wpsnipp.com Kevin Chard

          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.

          http://wpsnipp.com/contact/

        • http://wpsnipp.com Kevin Chard

          Hi Ken,
          It does not appear that this is the whole file however if it is I fixed the problem.
          http://pastebin.com/dzK56W4v

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

  • http://blog.justindorfman.com jdorfman

    thanks!

  • Falle

    Brilliant! Been looking for this for a while!

jqsnipp.com | we just launched jquery snippets website