• I have some HTML comments in the post.
    When rendered, the comments are enclosed into a paragraph with an additional line break like:

    <p><!--mycomment!--><br /></p>

    Is it WordPress or some plugin that does so? How to disable this beahviour?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Doesn’t do it in HTML mode on my installs…

    If you’re writing that in visual mode then the text is parsed as literal text and not code, so naturally it will be given a paragraph and linebreak.

    Thread Starter Blutarsky

    (@blutarsky)

    Actually the content is typed in HTML mode. There are no signs of HTML comments in visual mode….maybe a bug? Or a faulty plugin?

    Try this in HTML mode (the code in the following message)

    Thread Starter Blutarsky

    (@blutarsky)

    <!--pagetitle!-->
    <!--beginspoiler!-->
    <div class="jumps">In a rush?
    Jump to <a href="somelinkhere">the solution in a nutshell!</a></div>
    <!--endspoiler!-->

    Try the code above in a post

    Yes i see the problem… and i’ve been toying in HTML mode a little to get an idea of the issue.

    Tested….

    Test post 1:

    <p> test</p>
    test
    <span>test</span>
    <!--test-->

    Result 1:

    <p> test</p>
    <p>test<br />
    <span>test</span><br />
    <!--test--></p>

    Test post 2:

    <div>
    <p> test</p>
    test
    <span>test</span>
    <!--test-->
    </div>

    Result 2:

    <div>
    <p> test</p>
    <p>test<br />
    <span>test</span><br />
    <!--test-->
    </p></div>

    Test post 3:

    <div>
    <p>test</p>
    <p>test</p>
    <span>test</span>
    <!--test-->
    </div>

    Result 3:

    <div>
    <p>test</p>
    <p>test</p>
    <p><span>test</span><br />
    <!--test-->
    </p></div>

    Seems to me the issue depends on what elements are present and how they are nested. I hope the above helps…

    Thread Starter Blutarsky

    (@blutarsky)

    Thanks for the in-depth test!
    I’ll do some testing too.

    Thanks again

    oste15

    (@oste15)

    I have the same problem.

    When adding <span></span>

    It outputs
    <p>
    <span></span>
    </p>

    As per: folkspants.com/wordpress/theming/remove-paragraph-tags-from-your-wordpress-posts-so-your-media-stays-put
    Comment out line 110 of wp-includes/default-filters.php :

    add_filter( ‘the_content’, ‘wpautop’ );

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Does the_content() adds extra <p> & <br> to HTML comments?’ is closed to new replies.