php – WordPress editor add and remove tag<p> . How to turn it off?

Question:

The editor automatically adds p tags
To include this in the page template added

<?php 
remove_filter( 'the_content', 'wpautop' ); // Отключаем автоформатирование 

the_content(); ?>

But now, when switching between the "Visual" and "Text" tabs, the p tags are removed.

How can I disable both auto-adding and auto-removing p tags for a page template?

Answer:

Add this code not to the page template, but to functions.php

Scroll to Top