WordPress.org

Ready to get started?Download WordPress

Forums

Retaining br tags in posts (11 posts)

  1. impirius
    Member
    Posted 7 years ago #

    Hi all. I've searched and found several posts dealing with the reverse issue (too many br tags!). However, I'd like to prevent WP from replacing the br tags in posts with newlines. I tried working backwards through the code but got lost after a while. Anyone know which function is responsible for this?

    (And yeah, CSS is the preferred way to deal with spacing, etc. etc., but try telling that to the people for whom I'm building the website!)

    Thanks everyone.

  2. KatGirl
    Member
    Posted 7 years ago #

    If it helps any, this was started and still not resolved.

    http://wordpress.org/support/topic/90105?replies=7

  3. wpautop is the function that's doing that. Remove the line that applies it to the_content in /wp-includes/default-filters.php or use a mini-plugin to remove_filter('the_content', 'wpautop');.

  4. impirius
    Member
    Posted 7 years ago #

    KatGirl: Thanks for the link; I'll keep an eye on that topic as well.

    Viper007Bond: Thank you for the advice. I commented out the line
    // add_filter('the_content', 'wpautop');
    but unfortunately, the issue persists. Assigning a class to the br tags prevents them from being deleted, but I'm not sure that's a good long-term solution.

  5. Hmm, odd.

  6. impirius
    Member
    Posted 7 years ago #

    Seriously!

    I know there's a Text Filter plugin which can be used to prevent WordPress from altering the post content coming out of the database; do you know of any which prevent it from altering the content going in?

  7. spencerp
    Member
    Posted 7 years ago #

    Is this the one you're referring to?
    http://wordpress.org/support/topic/62692?replies=16#post-333995

    spencerp

  8. impirius
    Member
    Posted 7 years ago #

    Yep, spencerp, that's the one! That solves half the problem; if only there was an equivalent plugin or hack that prevented the <br> <p> </p> tags from being stripped before the post is inserted into the database, I could use them both.

  9. Heh, I shoulda known that my friend Jeff woulda made such a plugin.

  10. spencerp
    Member
    Posted 7 years ago #

    Will something from this read, work for ya?
    http://www.michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/

    spencerp

  11. KatGirl
    Member
    Posted 7 years ago #

    To upate - I did as Viper007Bond suggested and commented out the_content' 'wpautop' and it worked.

Topic Closed

This topic has been closed to new replies.

About this Topic