disable automatic tag insertion in specific page template

puting this code in function.php

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

It disable automatic <p> and <br /> tag insertion in page template.

Read More

for example I have 3 page template which is index.php, single.php and taxonomy.php and all of that page template remove the automatic <p> and <br /> insertion, in my case, I want <p> and <br /> tag automatic in taxonomy.php. is tha posible?

Related posts

Leave a Reply

2 comments

  1. try this one….

    It disable automatic <p> and <br /> in specific post and costume post type.

    function wpc_remove_autop_for_posttype( $content )  
          {  
        // edit the post type here  
        'costume_post_type' === get_post_type() && remove_filter( 'the_content', 'wpautop' );
        return $content;  
       }  
    add_filter( 'the_content', 'wpc_remove_autop_for_posttype', 0 );
    
  2. You can use is_tax() to check if you are displaying the taxonomy archive page and only remove the filters if it does not return true.

    if ( ! is_tax() ){
        remove_filter( 'the_content', 'wpautop' );
        remove_filter( 'the_excerpt', 'wpautop' );
    }