Vous cherchez un moyen d’ajouter des boutons d’indice et d’exposant dans l’éditeur de WordPress ? Bien qu’il existe probablement un plugin pour cela, nous avons créé un extrait de code rapide que vous pouvez utiliser pour ajouter des boutons d’indice et d’exposant à l’éditeur.
Instructions:
Tout ce que vous avez à faire est d’ajouter ce code au fichier functions.php de votre thème ou dans un plugin spécifique à votre site:
function enable_more_buttons($buttons) { $buttons[] = 'sub'; $buttons[] = 'sup'; return $buttons; } add_filter("mce_buttons_3", "enable_more_buttons");
Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez consulter notre guide sur la façon d’ajouter correctement des extraits de code dans WordPress, afin de ne pas endommager accidentellement votre site.
Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : 20 meilleurs thèmes d’église WordPress pour agrandir le troupeau et comment démarrer 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.