Forums

HTML Comments Getting Wrapped in P Tag (8 posts)

  1. mattzellmer
    Member
    Posted 1 year ago #

    I use the HTML view when I edit the content on a page. When editing the HTML I add comments enclosed with comment markup (<!-- -->). However, when WordPress publishes the page it wraps all the comments in <P> tags which screws up the formatting of the page.

    Is this a bug or is there a setting somewhere where I can tell it not to add the <p> tags?

    Thanks!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    It's not a bug. You'd need to create a custom callback for wp_list_comments in your theme.

  3. mattzellmer
    Member
    Posted 1 year ago #

    Thanks. Any links to docs that will tell me how to do that?

  4. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Have a look at the page I linked to above.

  5. zenserve
    Member
    Posted 1 year ago #

    I don't think esmi understand the problem. mattzellmer is asking about how to remove the <p> tags around the html comments (not the blog user comments). I sometimes put some html comments saying what the <div> block is like

    <!-- start of main content -->
    <div id='maincontent'>
    some other tags or content
    
    </div>
    <!-- end of main content -->

    After I save this in the editor within wp-admin, WP render my content like this

    <p><!-- start of main content --></p>
    <div id='maincontent'>
    some other tags or content
    
    </div>
    <p><!-- end of main content --></p>

    This has caused a problem for the layout

    [Please post code snippets between backticks or use the code button.]

  6. zenserve
    Member
    Posted 1 year ago #

    OK, I found a solution

    It was posted here.

    http://wordpress.org/support/topic/does-the_content-adds-extra-ltpgt-amp-ltbrgt-to-html-comments?replies=8

    you have to edit
    wp-includes/default-filters.php
    and comment out
    add_filter( 'the_content', 'wpautop' );

  7. mattzellmer
    Member
    Posted 1 year ago #

    Thanks for the help zenserve. I appreciate it!

    Matt

  8. zoonini
    help me help you
    Posted 1 year ago #

    Rather than editing a core file - meaning that your change will get overwritten every time you upgrade WordPress - I strongly recommend that you add the filter to functions.php in your theme instead:

    http://codex.wordpress.org/Function_Reference/wpautop#Disabling_the_filter

Topic Closed

This topic has been closed to new replies.

About this Topic