This question is about HTML code comments <!-- like so --> rather than about post/page comments. I specify the WYSIWYG, but this problem arose in the HTML view, not the Visual.

I've been building a site for a client, and she came to me with a problem — she had tried to comment out part of her page content, and it had drastically changed the behavior of the page!

I looked into it, and was pretty surprised to find that putting a comment anywhere into the content would completely remove that entire block of content. And not just that, it seemed to be confusing WordPress as to what the_content() for that page even was. The content from the sidebar, if there was one, or the footer, if there was no sidebar, would work its way into the main content display area.

The only context in WP I've seen <!-- this --> before was in using the DagonDesign sitemap generator plugin, which you display by putting a <!-- commented out shortcode --> into the page content. That seems to have been co-opted for a special purpose, but is there a purpose for the comment tag that I am not familiar with?

Does anyone have insight into what's going on here?

1 Answer 1


This is a duplicate of another question and (I'm sorry!) a bug in WP. As @Otto says in the comments to that question, this is an edge case problem (not many users know or care about using comments) and is not likely to get fixed soon unless you'd be interested in contributing.


I looked for more information on this in trac, and found a few related bugs describing exactly this problem. There is a workaround suggested:

Just before the close comment tag, put another open comment tag. That second open comment tag will be commented out, but it forces the close tag to be recognized and not be reformatted as an en-dash.

Example that fails: <!-- <b> text </b> -->

Example that works: <!-- <b> text </b> <!-- -->

In other words, if you have comments that enclose other tags, just make sure the last tag is another open comment tag.

Hope this helps! (Better late than never!)

  • 1
    Well, technically, that other question is a duplicate of this one... I beat them to it by a few months. But let's not split hairs. Thanks for the answer! Commented Jan 7, 2013 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.