WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. andrej1c
    Member
    Posted 5 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
    Member
    Posted 5 years ago #

  3. andrej1c
    Member
    Posted 5 years ago #

    whoami,

    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.

    Andrej

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    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
    Member
    Posted 5 years ago #

    Otto42,

    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.

    Andrej

Topic Closed

This topic has been closed to new replies.

About this Topic