I am trying to figure out the best way to disable wpautop in 4 custom post types.
I am using this snippet:
add_filter( 'the_content', 'wp1_remove_autop_for_posttype', 0 );
function wp1_remove_autop_for_posttype( $content )
{
'esh' === get_post_type() && remove_filter( 'the_content', 'wpautop' );
return $content;
}
I also need to remove it for custom post types named menu, op, external. do i just copy and paste this and change the function name or is there a cleaner way to do it?
wisdom appreciated! thanks!
You can make array with all
CPT
that you need to removewpautop
from, and then in this hook to do:You can check this function get_post_types(), if you want to grab
CPTs
automatically. For instance, if you want to loop through all yourCPTs
:or of course, you can put other arguments to select needed types that you want to loop through.