X

Como adicionar o botão de regra horizontal ao editor no WordPress

Snippets by IsItWP

Você está procurando uma maneira de adicionar um botão <hr /> ao editor? Embora provavelmente exista um plug-in para isso, criamos um trecho de código rápido que você pode usar para adicionar um botão de regra horizontal ao editor no WordPress.

Instruções:

Tudo o que você precisa fazer é adicionar esse código ao arquivo functions.php do seu tema ou em um plug-in específico do site:

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

add_filter("mce_buttons", "enable_more_buttons");

Observação: Se esta é a primeira vez que você adiciona trechos de código no WordPress, consulte nosso guia sobre como adicionar corretamente trechos de código no WordPress para não danificar acidentalmente seu site.

Se você gostou desse snippet de código, considere dar uma olhada em nossos outros artigos no site, como: 9 melhores plug-ins imobiliários do WordPress e como configurar o rastreamento de comércio eletrônico do Google Analytics para o WooCommerce.

Comentários   Deixe uma resposta

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

  2. thanks!

  3. thank you for the quick code..

  4. Simon Codrington março 27, 2012 em 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.

          http://wpsnipp.com/contact/

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

  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 março 5, 2011 em 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 fevereiro 25, 2011 em 2:59 pm

    Useful!

    1. yes the other things you could do is create a few shortcodes to drop in html elements you need. Check out this snippet.
      http://wpsnipp.com/index.php/functions-php/add-custom-media_buttons-for-shortcode-selection/

  9. Pippin Williamson fevereiro 25, 2011 em 2:48 pm

    Excellent!

    1. thanks pippin

Adicionar um comentário

Ficamos felizes por você ter optado por deixar um comentário. Lembre-se de que todos os comentários são moderados de acordo com nossa política de privacidade, e todos os links são nofollow. NÃO use palavras-chave no campo do nome. Vamos ter uma conversa pessoal e significativa.

WordPress Launch Checklist

A lista de verificação definitiva para o lançamento do WordPress

Compilamos todos os itens essenciais da lista de verificação para o lançamento de seu próximo site WordPress em um ebook prático.
Sim, envie-me o livro eletrônico gratuito grátis!