Added <p> </ p> and <br> at pages

Please tell me how to fix the problem in the ROOTS that in articles and pages he spontaneously Added <p> </ p> and <br>? A very important issue.


Not sure why this is tagged as Bedrock?

The wpautop function is a common cause of this issue in WordPress, so it would help if you could try one of the default themes and confirm if it’s isolated to Roots only.

1 Like

I’d agree with Foxaii on this one - verify that it is an isolated issue and not just the global wpautop function doing its job.

David Walsh has a great post about disabling the wpautop function if you choose to go down that path. Simply add the following to your functions.php file.

remove_filter('the_content', 'wpautop');
1 Like

I know about “wpautop” for a long time. But it is not a cure, but a crutch. It removes all <p> in the article.

Thanks. There is a solution [raw][/raw] but can not find anywhere such that it is still in the code, and worked as a shortcode.

Did you try another theme to see if it’s a Roots only issue?

Try disabling plugins also, as you will occasionally find some that don’t play nice with wpautop.

Yes, of course, it’s the first thing I did. :slight_smile:

If it’s a Roots only issue then you’ll have to create an unformatted gist with the post content and the produced output.

I found more enhanced way to remove wpautop() from a certain page.
The following code works good if I paste it to the functions.php, but when i try to paste to extras.php it doesn’t work.
Can you please tell me what I do wrong?

     * When to apply wpautop();
    add_filter('the_content', 'specific_no_wpautop', 9);
    function specific_no_wpautop($content) {
        if (is_front_page()) {
            remove_filter( 'the_content', 'wpautop' );
            return $content;
        } else {
            return $content;
1 Like

If you have an issue with something, it’s probably better to 1) Check for errors/warnings, 2) search for those errors here on Discourse and on Google, and then finally 3) start your own discussion

However, since has been a recurring issue for users, I’m pretty sure this is your issue: