2

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

1 Answer 1

12

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);
}
1
  • This worked. Just don't like that you have to remove wpautop in it's entirety, then add it back. Anyway.
    – Foxinni
    Oct 4, 2012 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.