• Resolved Amāvāsyā Cowboy

    (@tikimaticdotcom)


    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

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 https://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.

    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.

    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.

    Thread Starter Amāvāsyā Cowboy

    (@tikimaticdotcom)

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

    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;
    }

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

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com 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: https://ottodestruct.com/wpstuff/disableautop.zip

    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.

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.