Share

There are times when we want to get rid of wp_autop filter. This little fellow removes paragraph and linebreaks
tags and autogenerates them where he thinks they should occur. From time to time this is quite troublesome and we simply want to get rid of that.

But do we really know what would be the consequences of that?

[php]

remove_filter( ‘the_content’, ‘wpautop’ );

function new_wp_content($content) {
return $content;
}

add_filter( ‘the_content’, ‘new_wp_content’ );
[/php]

This will not only affect content display for each page and post, but also our RSS feeds, making them mostly unreadable.

This is where WP conditional tags come in handy, with a simple trick it will keep our feeds untouched.

Yeah, you can whatever you want with that code above, stop nerding 😛

[php]

remove_filter( ‘the_content’, ‘wpautop’ );

function new_wp_content($content) {
if (is_feed())
return wp_autop($content);
else
return $content;
}

add_filter( ‘the_content’, ‘new_wp_content’ );
[/php]

The following two tabs change content below.
WordPress Blogger, Certified Codeable Expert Developer, Senior WordPress developer. Having worked with WordPress for over 8 years creating plugins, themes and WordPress based applications. I am wordpress.org contributor, CodeCanyon creator and YouTuber.