WordPress.org

Ready to get started?Download WordPress

Forums

WP Adding <p> automatically? (8 posts)

  1. WillAugust
    Member
    Posted 5 years ago #

    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>
    </p>

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

    Thanks
    -Will

  2. Saurus
    Member
    Posted 5 years ago #

    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.

  3. WillAugust
    Member
    Posted 5 years ago #

    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.

  4. WillAugust
    Member
    Posted 5 years ago #

    Bump

  5. trulyandy
    Member
    Posted 5 years ago #

    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.

  6. 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.

  7. zrenneh
    Member
    Posted 5 years ago #

    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!

  8. trusktr
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags