Disable TinyMCE autoformatting

I am trying to understand some basic concepts of WordPress.

Let’s say I am a coder and I made a template for my client. I am at the point when some basic layout of the page is complete and now I want to fill in some text. I will use WordPress Pages for this so my client can edit the texts whenever he wants.

Now I want to add the client’s address on the page. It requires using some DIV structure to have the address nice on the page. I add this code directly to the Contact Page using TinyMCE (edit post) and HTML tab. I save the article and voila, the address seems to have the correct data and correct CSS styles.

What happens to me now is that I go back to Page editing, it automatically opens the HTML tab (because I used it last time) and when I go to Visual tab, I do nothing else but going back to HTML tab, my code breaks and if I save the page at this point, my client address layout breaks too.

This code:

<div class="item">
<div class="content">

Becomes this:

<div class="item">

&nbsp;
<div class="content">

And it is all because I switch to Visual tab and back to HTML tab.

Moreover, this new “paragraph” actually becomes

<p></p>

And that is what breaks my page in the end.

What is the solution for this?

5 Answers
5

You can add this code to your function.php file of your theme

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

or you can use this plugin for easier control

Leave a Comment