Remove auto add of p tag on specific template in WordPress

This function will remove the auto adding of “<p>” tag on specific page template for wordpress.

function autop(){

   global $wp_query;

   $page_id = $wp_query->post->ID; 
   $template = get_page_template_slug($page_id); 

   if($template == 'templates/full-width-no-container.php'){ // template name
      remove_filter ('the_content', 'wpautop'); remove_filter ('the_excerpt', 'wpautop');

} add_action('wp','autop');
John Perri Cruz

About the Author

John Perri Cruz was born in the Philippines, at the cold month of december. (Not cold enough cause Philippines is a tropical country.)

He's currently working as a Fullstack Web developer and when not sleeping, he can be found in coffee shop most of the time.

He gained his experience and skills by making and developing websites and systems for various individuals. He is well equipped with different Web programming languages and tools.

Connect :

Buy me a cup of coffee :

1 Comment

Leave a Reply