Javascript in a post? Remove all white space in the script and the WP editor won’t add paragraph returns.
Or make a shortcode: http://codex.wordpress.org/Shortcode_API
Thread Starter
zel
(@zel)
Problem is somewhere else – it keeps adding the <p> before images, and that’s messing up all.
Put in functions.php and then put the <!-- noformat on --> and <!-- noformat off --> tags around post/page content you don’t want formatted by the editor.
// <!-- noformat on --> and <!-- noformat off --> functions
function newautop($text)
{
$newtext = "";
$pos = 0;
$tags = array('<!-- noformat on -->', '<!-- noformat off -->');
$status = 0;
while (!(($newpos = strpos($text, $tags[$status], $pos)) === FALSE))
{
$sub = substr($text, $pos, $newpos-$pos);
if ($status)
$newtext .= $sub;
else
$newtext .= convert_chars(wptexturize(wpautop($sub))); //Apply both functions (faster)
$pos = $newpos+strlen($tags[$status]);
$status = $status?0:1;
}
$sub = substr($text, $pos, strlen($text)-$pos);
if ($status)
$newtext .= $sub;
else
$newtext .= convert_chars(wptexturize(wpautop($sub))); //Apply both functions (faster)
//To remove the tags
$newtext = str_replace($tags[0], "", $newtext);
$newtext = str_replace($tags[1], "", $newtext);
return $newtext;
}
function newtexturize($text)
{
return $text;
}
function new_convert_chars($text)
{
return $text;
}
remove_filter('the_content', 'wpautop');
add_filter('the_content', 'newautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'newtexturize');
remove_filter('the_content', 'convert_chars');
add_filter('the_content', 'new_convert_chars');
How are you disabling the wpAutop filter? it can be tricky to remove. Are you using something like this:
remove_filter ('the_content', 'wpautop');
if so read up on here: http://wordpress.org/support/topic/removing-wpautop-filter?replies=11
It could be a priority problem. I suggest that you add this as close to the output of the content (before, not after), and call it as late as possible in the load process (e.g. in the template files if possible).
What theme are you using?
Have you tried this plugin? http://www.bake-the-web.de/2012/03/22/no-wpautop/