Support » Fixing WordPress » how remove <p></p> tags automatically generated in <div class=”entry”>

  • Resolved tikimaticdotcom


    if you write a post which content is:


    then the result is

    <div class="entry">



    thats is

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

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

    thank u

Viewing 11 replies - 1 through 11 (of 11 total)
  • 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.

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

    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!

    The tags are probably added by a filter – wpautop

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


    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.

    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.

    to answer pidge’s curiosity, the reason was to have posts displayed inline.
    ( )
    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.

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

    how do u use css to negate the P tag?

    p {
    display: inline;

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    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:

    Thanks 0tto42 1000x 🙂

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


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


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

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

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘how remove <p></p> tags automatically generated in <div class=”entry”>’ is closed to new replies.