I am using this code to remove the autop generated by wp.
remove_filter('the_content', 'wpautop');
All good, but I need to have the autop only in the blog articles.
After searching I found that I can detect if its a post or not, mixing another question and wp doc came up with this wasnt working until Matt pointed the error. Belows code is working right on wp 4.7.3.
remove_filter('the_content','wpautop');
add_filter('the_content','if_is_post');
function if_is_post($content){
if(is_singular('post'))
return wpautop($content);
else
return $content;//no autop
}
If you want the wpautop filter applied only in posts, then your if statement is backwards. Right now, you're removing the filter and if the current post type is post, it stays removed. Believe your code should look like this.
remove_filter('the_content','wpautop');
add_filter('the_content','if_is_post');
function if_is_post($content){
if(is_singular('post'))
return wpautop($content);
else
return $content;//no autop
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With