How to avoid auto-inserting <p> and <br> tag in Wordpress?

Creation & Innovation

Moderator: Moderators

How to avoid auto-inserting <p> and <br> tag in Wordpress?

Postby praveen-r » Tue Dec 08, 2009 3:19 am

One of the annoying features of the popular blogging platform Wordpress, is its automatic correction and presumed way of editing the HTML code you insert in creating your posts.Here we are facing this issue in many cases. Now a stage occurred in Matrix that We can't move ahead without solving this. Anybody able to help us?
we already used 3-4 plugins for fixing it so please avoid those..
1. NoAutoP
2. Disable wpautop
3. ps-disable-auto-formatting
4. If we are using FCK editor we can solve this, but that time we can't include php.
5. Edited function.php and inserted <?php remove_filter ('the_content', 'wpautop'); ?>. But no change. :(
praveen-r
 
Posts: 212
Joined: Mon Sep 01, 2008 1:47 am

Re: How to avoid auto-inserting <p> and <br> tag in Wordpress?

Postby anit » Wed Dec 09, 2009 12:48 am

We can preventing WordPress from adding <p> and <br> tags completely in our posts/contents. Just modify this page /wp-includes/formatting.php

Change the following line

function wpautop($pee, $br = 1) {

to
function wpautop($pee, $br = 0) {

AND

comment this line for preventing extra <p> tags

$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee);


:)
anit
 

Re: How to avoid auto-inserting <p> and <br> tag in Wordpress?

Postby praveen-r » Wed Dec 09, 2009 1:35 am

Thanks Anit for your solution.. We can find many doubts posted in different forums asking this doubts. The solutions on those post are not working perfect. This may be a good solution for all those. I Appreciate your interest & perseverance on finding a solution ourselves...
praveen-r
 
Posts: 212
Joined: Mon Sep 01, 2008 1:47 am

Re: How to avoid auto-inserting <p> and <br> tag in Wordpress?

Postby tvjames » Wed Dec 09, 2009 2:13 am

great work as always Anit !!! :D
tvjames
 


Return to Web Design

Who is online

Users browsing this forum: No registered users and 50 guests