WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how remove <p></p> tags automatically generated in <div class="entry"> (12 posts)

  1. tikimaticdotcom
    Member
    Posted 8 years ago #

    if you write a post which content is:

    hello

    then the result is

    <div class="entry">
    <p>

    hello

    </p>
    </div>

    thats is

    <div class="entry">
    <?php the_content() ?>
    </div>

    how do i remove these paragraph tags?
    (not using the visual rich text editor does not solve)

    thank u

  2. tboley
    Member
    Posted 8 years ago #

    Currently I use a filter and some reg-expressions to get ride of the -tags, but this doesn´t work very well. It would be nice if there is an easy solution for this.

  3. pidge
    Member
    Posted 8 years ago #

    Just out of curiosity, why would want to remove the markup (e.g. ) added (via hooks) by WP the_content() ?

  4. Doodlebee
    Member
    Posted 8 years ago #

    pidge -

    I could see why. Personally, I hate "p" tags. It's a personal preference, though - and I know you *should* use "p" tags - but for soem reason, they bug the crap out of me. I prefer to separate my paragraphs with
    tags, and place my other content (like titles, dates, author links, etc.) in whatever way I see fit - like span tags or divs, something like that. Sometimes those "p" tags just get in the way and drive me batty.

    But again, that's a personal preference!

    But on to the question at hand: I don't know where you go in the files to remove the "p" tags, but you *can* use CSS to work around them. All you have to do is style them in the styles.css file to your liking - so even though it's a PITA (again, personal view!) it *is* something you can work around and get it to do what you want. ;)

    Hope that helps a little bit!

  5. ebusiness
    Member
    Posted 8 years ago #

    The tags are probably added by a filter - wpautop

    See http://www.uberdose.com/journal/archives/2004/07/17/mime-wordpress-plugin/ for an idea on how to disable it on a post by post basis - extreme but wpautop gets in the way of correct xhtml many times.

  6. pidge
    Member
    Posted 8 years ago #

    Doodlebee,

    Thanks for the response re: a reason. (I thought it may have been a due to a technical issue).

    There are some theories out there (can't remember where I read it), but using structural mark up seems to help in the SEO side (easy for the crawler/indexer code to interpret your content, maybe?). Also helps with validation and non-traditional browsers/webpage readers (i.e. for Accessibility such as for the visually impaired)

    Like you said, modifying the style sheet is a good option. The newlines are converted in the wpautotp function (as ebusiness pointed out). One could modify that function to use div tags. (to wrap newlines).

    Better yet, add a new plug-in that converts all para tags to div tags (not sure if one exists) during presentation.

  7. KKWangen
    Member
    Posted 8 years ago #

    Structual, sematic markup does help a crawler to interpret your content.

    So you *should* use the p-tag for paragraphs and <div> for blocks only and <span> only for elements that stand out of the usual coding.

  8. tikimaticdotcom
    Member
    Posted 8 years ago #

    to answer pidge's curiosity, the reason was to have posts displayed inline.
    ( http://www.tikimatic.com/dev/refs/screen/ )
    so as doodlebee pointed out , the easiest way is to CSS that - what i finally did.

    btw thank you for mentioning wpautop, i'll dive into it when i've got time.

  9. dionysus28
    Member
    Posted 7 years ago #

    how do u use css to negate the P tag? it was suggested, but i do not know how to do this

  10. Kafkaesqui

    Posted 7 years ago #

    "how do u use css to negate the P tag? "

    p {
    display: inline;
    }

    http://www.w3schools.com/css/pr_class_display.asp

  11. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    If you still want to disable autop for whatever reason (although it's rarely a good idea), here's a plugin to make it simple: http://ottodestruct.com/wpstuff/disableautop.zip

  12. alainS
    Member
    Posted 7 years ago #

    Thanks 0tto42 1000x :)

    Just a clarification why I needed this badly. With P elements wrapping DIVs I wasn't able to validate the xhtml.

    BEFORE OTTO42:


    <div class="photo">
    P<img alt="img" src="img.jpg" />P
    </div>
    <div class="txt">
    Psome txtP
    </div>
    P<br class="clear" />
    </div>

    AFTER OTTO42:


    <div class="photo">
    <img alt="img" src="img.jpg" />
    </div>
    <div class="txt">
    some txt
    </div>
    <br class="clear" />
    </div>

    Note the opening P before BR in first example without closing P tag.

Topic Closed

This topic has been closed to new replies.

About this Topic