I generated some custom post types in Wordpress where I need to add some html code to the post. The problem is that wordpress adds some nasty paragraphs all over my code and it`s breaking my lines. Is there any wa开发者_如何学Pythony to remove extra paragraphs generated by wordpress for this specific post type?
I use a custom loop for the posts and a single-posttype.php files so I have full control over the general output.
you can remove the wpautop filter on the content by putting this into the functions.php of your theme by doing like this :
remove_filter('the_content','wpautop');
//decide when you want to apply the auto paragraph
add_filter('the_content','my_custom_formatting');
function my_custom_formatting($content){
if(get_post_type()=='my_custom_post') //if it does not work, you may want to pass the current post object to get_post_type
return $content;//no autop
else
return wpautop($content);
}
精彩评论