Where in the code does WordPress re-add paragraph tags to the content? (5 posts)

  1. andrej1c
    Posted 7 years ago #

    When you look at the html of your post or page (or what is stored in $wpdb->posts.post_content), you'll notice that there are no <p>'s but instead just double spaces. Somewhere between when WordPress reads the content from the database and when it displays it on the page, it recreates a <p> from double spaces.

    Why do I need to know? I whipped up a little hack/plugin that adds the TinyMCE editor onto the excerpt field to allow for formatting. All works fine, except for the functionality I described above. For example:

    What I put in:
    First line

    Second line

    Third line

    What gets displayed:
    First line Second line Third line

    Thanks! Any help would be appreciated.

  2. whooami
    Posted 7 years ago #

  3. andrej1c
    Posted 7 years ago #


    That filter is run on both Content and Excerpt. I see no change when I disable the filter (/wp-includes/default-filters.php. I wish you were right though.


  4. Sorry to burst your bubble, but whooami is correct. wpautop is the only filter in the code that adds those P tags to the content. If disabling it did not work for you, then you did not actually disable it correctly or something.

    Are you using page caching, perhaps? WP-Super-Cache?

    Also, it doesn't turn "double spaces" into a P. It turns double line breaks into paragraph markers.

  5. andrej1c
    Posted 7 years ago #


    Thanks for your response. I will look into disabling wpautop another way (other than commenting it out in /wp-includes/default-filters.php which I already tried). Any chance you can suggest a specific approach?

    I'm not using any server-side cache and cleared my browser cache, just to be sure.

    You know what I meant by double-spaces so I'm not sure why you feel the need to correct me.


Topic Closed

This topic has been closed to new replies.

About this Topic