• When I use the WordPress HTML editor to add icomoon icons like this

    <span class="icon-shield"></span>

    and then switch to the visual editor and then back to the HTML editor, the icons disappear. I am trying to include this bit of Javascript to fix this. I looked at wp_enqueue_scripts and put this in functions.php, but it still doesn’t fix the problem.

    function oakwood_tinymcefix() {
        wp_enqueue_script( 'tiny_mce' );
        echo '<script type="text/javascript">'
       , 'tinymce.init({
                ...
                extended_valid_elements : "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]"
            });'
       , '</script>';
    }
    add_action( 'admin_enqueue_scripts', 'oakwood_tinymcefix' );

    How can I fix this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Don’t switch editing tabs. That’s the fastest way to remove some (or all) of your markup due to the way in which the TinyMCE visual editor works. Use the Text tab for this Post or Page and then stick to it.

    Thread Starter mcography

    (@mcography)

    This is a problem on every post. Unfortunately, I’m building this site for a client who doesn’t know HTML that well. They’ll want to use the visual editor. I can’t tell them to just use the HTML editor. Kind of defeats the purpose of WordPress as a content-editor-friendly CMS, doesn’t it? Isn’t there a way to fix this?

    Isn’t there a way to fix this?

    Not the tab switching issue, no. Perhaps you need to approach this from another direction? Especially if you are adding lots of markup to Posts and/or Pages.

    Thread Starter mcography

    (@mcography)

    That’s disappointing. What’s the point in being able to switch tabs then?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress Visual Editor Stripping HTML Changes’ is closed to new replies.