¿Estás buscando una forma de añadir botones de subíndice y superíndice al editor de WordPress? Si bien es probable que haya un plugin para esto, hemos creado un fragmento de código rápido que puede utilizar para agregar botones de subíndice y superíndice al editor.
Instrucciones:
Todo lo que tienes que hacer es añadir este código al archivo functions.php de tu tema o en un plugin específico del sitio:
function enable_more_buttons($buttons) { $buttons[] = 'sub'; $buttons[] = 'sup'; return $buttons; } add_filter("mce_buttons_3", "enable_more_buttons");
Nota: Si es la primera vez que añade fragmentos de código en WordPress, consulte nuestra guía sobre cómo añadir correctamente fragmentos de código en WordPress, para no romper accidentalmente su sitio.
Si te ha gustado este fragmento de código, por favor, considere revisar nuestros otros artículos en el sitio como: 20 mejores temas de WordPress para iglesias para ampliar el rebaño y cómo iniciar un blog.
When I try this I get “syntax error, unexpected end of file”
You may want to check that the whole snippet was copied.
Be sure to check out: https://www.isitwp.com/properly-add-code-snippets-wordpress-site/
It is not working with the Elementor’s editor
Sadly this snippet is not designed to work with Elementor and will most likely only work with the classic editor.
This no longer seems to work. Any idea why?
Commented this elsewhere, but just incase:
For Anyone looking at this using WordPress on a version later than 3.9 that has TinyMCE 4 the function above won’t work, this is because WordPress and TinyMCE changed ‘sup’ to ‘superscript’ and ‘sub’ to ‘subscript’ – If you make those changes in the code above it will work fine!
I am getting a Missing argument 1 for enable_more_buttons() error
you saved my day man
thanks fot tip
Just what I was looking for!
When I add it, I get a
Fatal error: Call to undefined function add_filter()
Perfect little piece of code! Works brilliant. Thanks a lot!
No problem glad that I could help!
thanks guys. i was working with a PhD client today who writes research
reports and it was necessary for her to sup and sub references. this
was key.
Perfect Jerry glad to hear you got things working well.
(text translated by the program)
Thank you for providing this code, but no need to repeat the array code, simply separate the items in the array
function enable_more_buttons($buttons) {
$buttons[] = ‘sub , sup’;
return $buttons;
}
add_filter(“mce_buttons_2”, “enable_more_buttons”);
This is true, I just find this method easier to read. Thanks for the input though people will find this very useful.