Disabling Automatic Post and Page Formatting in Wordpress Themes
Problem
Sometimes when working on Wordpress powered sites, especially those that require a lot of custom HTML/CSS formatting through the HTML tab of the editing page, you’ll run into instances where the automatic formatting Wordpress uses becomes really annoying. Wordpress runs a filter on the content of your pages and posts that automatically adds in paragraphs where you might not want them sometimes.
Obviously if you’re sticking to writing relatively simple posts without too much formatting, this isn’t a big deal. But if you using a lot of custom CSS styles in your pages to style pages in a more radical way without having to mess with template files, you’ll need a solution that allows you to bypass that automatic formatting.
Solution
There are a few ways to filter your automatic formatting in Wordpress but the following is the best. You need to add a bit of code directly in front of the call to “the_content()” that disables the filtering. So instead of calling the_content like you normally do in a theme page:
<?php the_content(); ?>
…you would add a single filter directly in front of that comment, like so:
<?php remove_filter ('the_content', 'wpautop'); ?> <?php the_content(); ?>
That will disable the formatting of the body of your page. Be careful with using this filter tag, as all of the clean formatting that Wordpress normally applies will disappear when you use it. Your best bet is to create a copy of whatever template page you want this to be applied to and rename it so you can select it as a custom template when writing your new page.
Related posts:









I am relatively new to WordPress. I want to disable the auto-formatting in the new Pages(currently Private) that i added for the various links on my sidebar.
I added php code in those pages to fetch data from the database and display them in tables. But currently my complete page gets filled with auto and tage. How do i apply your code to remove the auto-formatting from those pages
Reply to this person's comment
I figured out that the page.php (template) was getting applied to all my pages defined.(Pardon the ignorance of this newbie)…
However even after i applied this to my template, the auto-formatting did not go.
I am using WP 2.8.4.
Any clues?
Reply to this person's comment