WordPress.org

Ready to get started?Download WordPress

Forums

wpAutop - can't disable it (5 posts)

  1. zel
    Member
    Posted 1 year ago #

    Hello again all,
    I need to get rid of that <p> tags in just ONE site, and every solution i found on the web doesnt work :( nor editing functions and adding remove filter, nor plugins. Those damn <p> keep inserting without my permission.
    Is there any way to get rid of it?
    I can even manually edit somewhere that one page, because there are 4 <p> which completly destroys my script. But I don't know where to find it.
    please help :)

  2. 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

  3. zel
    Member
    Posted 1 year ago #

    Problem is somewhere else - it keeps adding the <p> before images, and that's messing up all.

  4. 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');
  5. rfair404
    Member
    Posted 1 year ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.