Keep control over the way WordPress formats your posts

November 17th, 2010

If you format your pages in HTML, or even paste copy from other sources you may find that WordPress does some quirky things like adding manual like breaks where you don't want them. Users switching back and forth between regular and code view have also noticed WordPress adding classes or div's. If you want to keep complete control over your formatting, you can disable WordPress's formatting filters by editing your functions.php file.

wpautop & wptexturize

wpautop is a filter that adds <p>'s and <br />'s to your pages and posts, sometimes when you don't want it to do so. wptexturize formats your special characters and may do things like converting straight quotes to curly quotes when you really wanted the former. You can disable wpautop and wptexturize by adding the following code to the functions.php file in your theme directory. (If you don't have a functions.php just create a blank file, add the following and save as functions.php.)

Note: You should only do this if you plan to write all of your pages and posts in HTML as disabling this filter will mean that <p>'s are no longer added, even in WYSIWYG mode. If adding this to an existing site you will have to ensure that all your previously created pages are also formatted in HTML.

//disable auto p
remove_filter ('the_content', 'wpautop');
//disable wptexturize
remove_filter('the_content', 'wptexturize');?>

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • StumbleUpon
  • MySpace
  • LinkedIn

Categories: WordPress Tips

Tags: ,

No Comments »

No comments yet.

Leave a comment

RSS feed for comments on this post. | TrackBack URL