Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

EDIT:

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!)

share|improve this answer
    
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! –  heathenJesus Jan 7 '13 at 16:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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