Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to try and remove automatic <p> tag and <br> tag addition for my custom post type.

It looks like

remove_filter( 'the_content', 'wpautop' );

will do this, but how would I make the change only for my chosen post type I've tried writing a function for this, but it doesn't seem to work:

function remove_tags() {
    global $post_type;

    if ( 'client' == $post_type ) {
        remove_filter( 'the_content', 'wpautop' );
share|improve this question
Where are you putting these functions? – s_ha_dum Jan 23 '13 at 23:15
in my custom post type plugin file – user319940 Jan 23 '13 at 23:16

2 Answers 2

Hook into the_content before the wpautop filter has been called, check the post type, and remove the wpautop filter, which is added in wp-includes/default-filters.php with the default priority 10:

add_filter( 'the_content', 'wpse_82860_remove_autop_for_posttype', 0 );

function wpse_82860_remove_autop_for_posttype( $content )
    # edit the post type here
    'post' === get_post_type() && remove_filter( 'the_content', 'wpautop' );
    return $content;
share|improve this answer
After years, I still have problems understanding priority handling of filters in WP. Doesn't 0 mean that it's first called and after that the default wpauto is called with its priority of 10 and puts the <p>s back in? – Volker E. Feb 1 at 0:52
@VolkerE. wpautop is not called anymore, because it has been unregistered earlier. – toscho Feb 1 at 0:55
Oh, for sure. Thanks! And it's not even late at my place right now. :} – Volker E. Feb 1 at 0:58
up vote 2 down vote accepted

//decide when you want to apply the auto paragraph


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
 return wpautop($content);

found this code on stackoverflow - looks to do the trick.

share|improve this answer
+1 for finding your own answer :) Please post the URL for the question where you found the code though. – s_ha_dum Jan 23 '13 at 23:29
original can be found here… – user319940 Jan 23 '13 at 23:33
This will break when another plugin wants to do the same for another custom post type. – toscho Jan 24 '13 at 3:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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