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.
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