• scorch

    (@scorch)


    Here’s what I have in the Loop:

    ‘<div class=”posttitle”><?php the_title(); ?> <?php edit_post_link(); ?></div>
    <div class=”postinfo”>Posted by: <?php the_author(); ?> @ <?php the_time() ?></div>
    <div class=”postentry”><?php the_content(); ?></div>’

    When the page renders the_content section shows up with a ‘p’ tag around it. How do I get rid of it?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • thinkeric

    (@thinkeric)

    Wondered this myself for the longest time, as I hate how IE-PC adds so much extra space between p tags. You need to hack the wp-includes > functions-formatting.php file. As always, work on a backup in case you hose something.

    You’re looking for this line, near 64:

    $pee = preg_replace("/n?(.+?)(?:ns*n|z)/s", "t$1
    n", $pee); // make paragraphs, including one at the end

    What I did is simply comment this out (add a // at the beginning). You can see where the p tags are edited, so if you have a custom div (in your case, it looks like it’s “postentry”), you modify the file by adding the following code:

    $pee = preg_replace("/n?(.+?)(?:ns*n|z)/s", "t<div class='postentry'>$1</div>n", $pee); // make paragraphs, including one at the end

    I did notice that I still get an extra br tag in there, so there’s probably more hacking to be done, but this is a good first step.

    sadish

    (@sadish)

    you cannot get rid of that, as it was generated by WP, when it reads the post content and store it in the DB.

    one possible option is to view source, copy the post u r interested in to a notepad, remove all < p > and close < / p > and then add < br / > in appropriate places and goto edit post, and paste it as one chunk of text.

    that may help u get rid of that. but then why the hazzle ?

    thinkeric

    (@thinkeric)

    Ah, check that…. the code isn’t going to like putting double-quotes where I put them. I have revised the code above so that the class “postentry” is in single quotes.

    navid

    (@navid)

    Semantically, <p> should go around paragraphs of text. That’s what it is for and it is being correctly used. If you do not like the spacing it generates, you should probably resort to using CSS:

    p {
    margin: 0;
    padding: 0;
    }

    For example, might generate the look and feel you are looking for without having to hack away at the WP core functionality. Thats my two-cents.

    Navid.

    thinkeric

    (@thinkeric)

    Good call Navid… I had forgotten that CSS trick (slaps forehead), thanks for the refresher…

    Thread Starter scorch

    (@scorch)

    I got so caught up with trying to banish the ‘p’ that I missed the obvious….thanks Navid.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Where’s the <p> coming from?’ is closed to new replies.