Having recently built a custom WordPress theme making use of the icon font Font Awesome, I came across an issue where the icon tag would be stripped from the TinyMCE editor.
Using the standard markup provided on the Font Awesome pages (Gamepad), the tag would be removed when alternating between Text and Visual editing mode.

<i class="fa fa-gamepad"> fa-gamepad
The first idea was to include a none-breaking space within the tag to provide some content within the tag and thus not empty.
<i class="fa fa-gamepad">
This does however have some drawbacks, including offsetting the icon and inconsistently being removed in the editor.
The second, more stable solution was to use a html comment tag, this doesn’t have the side effect of visually outputting any extra markup as per the previous option.
<i class="fa fa-gamepad"><!-- icon --></i>
This methos fully preserves the <i />
tag, without having to add any special TinyMCE rules or exceptions.
Other options include making use of the Font Awesome WordPress plugin, which includes the ability to use shortcodes in the editor to render icons.
Note: In this instance, the stylesheet for Font Awesome was directly embedded into my theme, instructions for this can be found on the Get Started page.
Thanks, Steve! I used our solution to add the comment tag and it works perfectly. You saved me a bunch of time.
LikeLike
Thanks for the tip Steve! The comment worked for me. It was driving me mad that this was being stripped out! I’m not keen on using the plugin but I might go for it just for ease of use.
LikeLike
Thank you very much for posting. Worked great.
LikeLike
Almost worked for me but now i get –> rendered beside each icon. It’s baffling.
using Font awesome 5 pro SVG
LikeLike