Blog Post: WordPress Paragraph Tag Fix

Red Deer & Blackfalds Web Design Writes:

For Developers who have chosen to utilize a CMS (Content Management System) for their websites, it can be frustrating when sub-par programming may have gone into template files that have been created. More specifically, when “fixes” were created to allow for a laman to operate their own website; however, shutting down creativity because of extra rules being established in Back-End Portal Text Editors.

Speaking specifically about WordPress there are a number of templates and themes developed that will automatically insert <p> tags into the code you are writing in the HTML editors found on individual pages and/or post pages. These are in place to try and regiment the output to the server and eventually the browser so that it essentially “tag-proofs” your post just incase you miss some vital bits of HTML when writing that could cause the output to look compressed and out of line with the rest of your page/post. A great concept! And honestly something that helped myself and a lot of developers/small-business-owners to allow for a greater output to their websites, but the problem lies when creating custom pages where even though working in a generic text editor, WordPress (and other CMS softwares) will create and place <p> tags freely, evidently destroying your layout and adding improper spacing and indentation.

When working with Responsive Design a great deal of the time you are working with percentages that take up as much space on a page as possible, and even one single unnecessary tag or indent could throw off your entire project, forcing you to write bad-code just to override these situations and in turn promoting bad practice. Below are two bits of code you can use (either on an individual page, or in your functions.php file) to override this “rule” and allow for more customizable creativity for your website!

*****Insert into functions.php to have whole site*****

remove_filter( ‘the_content’, ‘wpautop’ );
remove_filter( ‘the_excerpt’, ‘wpautop’ );

*****Single Page*****

Note: must have installed and activated InsertPHP WordPress Plugin

remove_filter( ‘the_content’, ‘wpautop’ );
remove_filter( ‘the_excerpt’, ‘wpautop’ );

Joshua Neufeld

Owner at Red Anchor Studio
At Red Anchor Studio we are dedicated to building local business! We offer high quality developments at an affordable price, and we can work to get your business online at any budget.

Latest posts by Joshua Neufeld (see all)