WordPress remove br tags on one specific page or page template

I have seen people remove br tags from wordpress by adding the following to the functions file:

remove_filter( 'the_content', 'wpautop' );

remove_filter( 'the_excerpt', 'wpautop' );

I would like this to affect only one page or page template. Is there any good way to do this? Like use a template name comparison in the functions.php?

Read More

EDIT:

For example I have tried the following without result in functions.php for my theme:

if( is_page_template("template_file_name.php") ){
    remove_filter( 'the_content', 'wpautop' );

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

Related posts

Leave a Reply

1 comment

  1. if you just want to remove all br

    can you try targeting that page with css?
    This will give the most flexibility

    .page-id-123 .content br { display:none; }