WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 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 stackoverflow.com/questions/7697465/… – 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

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 '15 at 0:52
@VolkerE. wpautop is not called anymore, because it has been unregistered earlier. – toscho Feb 1 '15 at 0:55
Oh, for sure. Thanks! And it's not even late at my place right now. :} – Volker E. Feb 1 '15 at 0:58

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.