• Hi All,

    I’m trying to do a few html comments in the HTML editor of wordpress. They seem to get into the database ok, but when I view the page I see a “->” and the page is messed up. When I view the source, the close of the html comment was changed from “–>” to “&# 8211;>” (but no space between the &# and 8211.)

    I’m using the html comment because I have a Java applet to show and it needs different “object” tags for IE vs. more standards compliant browsers. To do this, IE has “<!–[if !IE]>–>” and “<!–<![endif]–>” tags.

    Anyone have any ideas of how to pull this off?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Add this to your theme’s functions.php file:

    remove_filter('the_content', 'wptexturize');

    The WP editor tends to “eat” HTML comments contained in posts.

    When I test what you are attempting I find WP is wrapping each conditional comment in <p></p>

    If this is something like a static page, in other words, you are not going to be having a bunch of these, each different, from time to time, I’ve had success by creating a custom page template, and entering the code the WP editor doesn’t behave with in the template’s PHP file.

    If you need info on how to do this, see this:
    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
    You will also find other info on that page helpful.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Submitted as a bug report: http://trac.wordpress.org/ticket/8912

    Thread Starter sowelblack

    (@sowelblack)

    Thanks a bunch folks. The remove filter in the functions seems to have done the trick.

    stvwlf, I’ll keep that in mind in case I need to do something more complicated with Javascript. (But the reason I’m using WordPress and themes is to avoid all that stuff!) 🙂

    I need to add divisions to occasional posts and pages and I like to put a close comment at the end of the division as most of these are long.

    I am echoing the difficulty of stvwlf above – when putting HTML conditional comments in to the WP editor they are wrapped in “<p></p>” in the final output.

    If I put this into the editor:

    <div class="ednote">
    <p>Some Text</p>
    </div><!-- end .ednote -->

    The output is this:

    <div class="ednote">
    <p>Some Text</p>
    </div>
    <p><!-- end .ednote --></p>

    This is extra code; and it is also semantically wrong.

    These are occasionally used divisions so they can not be added the page template, and removing the ‘wptexturize’ filter does not fix this.

    Is there a solution I am missing?

    Thanks!

    I am using the latest version of WordPress (v.2.8.6) and am still getting the same response – as reported here, a year ago.

    It appears that although the comment tags work for text, ok,

      WordPress chokes on any attempt to comment out certain code.

    In my case, I only tried <p> and <address> tags: The following was the result:

    This:

    ‘<!– Comment <address></address> –>’

    was changed to this:

    ‘<p><!– Comment
    <address></address>
    <p> –></p>’

    Is there still no resolution ?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘HTML Close Comment Tag is getting modified’ is closed to new replies.