Support » Fixing WordPress » WP Adding <p> automatically?

  • Hey, having a bit of trouble with my <p> styles.

    <p class="newscontent"><?php the_content('more_link_text', strip_teaser, 'more_file'); ?></p>

    But in the browser it shows:

    <p class="newscontent">
    <p>The Content</p>

    So basically it is adding <p> tags which are over-riding my <p class=”newscontent”>. How do i stop this from happening?


Viewing 7 replies - 1 through 7 (of 7 total)
  • Which editor are you using? Are you pasting content from another writer? Why are you styling content from your php file? Content should be styled from your styles.css.

    I’m using Dreamweaver cs3, no i’m not pasting content, i made the theme myself and am using the wordpress php.
    It is styled from style.css, the stylesheet is linked to it.


    I noticed WordPress was also adding some </p> tags into my code automatically.

    I searched the forums for any possible solution but found nothing.

    I am also interested in why this is happening and how to prevent it.

    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Halfelf Rogue & Plugin Review Team Rep

    IIRC that feature is by design.

    When you enter in your content, WP wraps <p> tags around each paragraph. Change your <p class="newscontent"> to <div class="newscontent"> instead and then make a CSS for paragraphs in that class.

    Use plugin ‘PS Disable Auto Formatting’ to disable auto-insertion of <p> tags.

    The function the_content() adds the <p> tags automatically to paragraphs and strips out </br> tags.
    This feature is by design, but it can be very annoying e.g. if you want a straightforward way to have images wider than the text-block. Then you’d want to put your own <p> tags in, not around the images.

    Alternatively you can use get_post() to code your own post inserter, but this is pretty tricky!

    where can you edit the function the_content() so you can stop it from adding <p> tags?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WP Adding <p> automatically?’ is closed to new replies.