I've seen this question asked a few times, but none of the solutions have worked for me. Basically, when switching between TinyMCE and the HTML editor, my markup gets ruined.
I have a nested list on the page, like so:
<ul class="pageitem accordion-menu">
<li class="accordion-menu"><a class="accordion-child" href="#">Parent Link</a>
<ul class="accordion-menu-sub">
<li class="acc-sub"><a href="#">Link</a></li>
<li class="acc-sub"><a href="#">Link</a></li>
<li class="acc-sub"><a href="#">Link</a></li>
</ul>
</li>
(...)
</ul>
After switching to tinyMCE and back, it turns into this:
<ul class="pageitem accordion-menu">
<li class="accordion-menu"><a class="accordion-child" href="#">Parent Link</a><br />
<ul class="accordion-menu-sub">
<li class="acc-sub"><a href="#">Link</a></li>
<li class="acc-sub"><a href="#">Link</a></li>
<li class="acc-sub"><a href="#">Link</a></li>
</ul>
</li>
(...)
</ul>
HTML comments also don't work at all, but I have removed them for this example because I can live with that if need be.
I've tried disabling a lot of the content formatting options:
public function format_TinyMCE( $in ) {
$in['allow_conditional_comments'] = true;
$in['allow_html_in_named_anchor'] = true;
$in['block_formats'] = "Paragraph=p; Heading 3=h3; Heading 4=h4";
$in['convert_urls'] = false;
$in['doctype'] = '<!DOCTYPE html>';
$in['fix_list_elements'] = false;
$in['forced_root_block'] = false;
$in['relative_urls'] = true;
$in['remove_linebreaks'] = false;
$in['remove_trailing_brs'] = false;
$in['object_resizing '] = false;
$in['wpautop'] = false;
return $in;
}
add_filter( 'tiny_mce_before_init', 'format_TinyMCE' );
I have also disabled wpautop:
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
I have tried Don't Muck My Markup and it didn't work. I also have the HTML Editor Syntax Highlighter Plugin installed, but disabling it didn't make a difference.
Any help on how to stop unwanted reformatting from happening would be appreciated. Disabling either of the editor is not an option since it still needs to be editable for people without knowledge of HTML.