views:

83

answers:

3

Sometimes I need to inject some raw HTML code into a Wordpress post, and sometimes I need to comment out a chunk of that code.!

With a plain text editor, I can just use <!-- Comment --> around the chunk I want to hide.

But when I try this in a WP post, it does hide the code but I still see the "closing comment tag" -->.

What's the right way, if possible, to comment out code in a WP post?

Thanks!

A: 

Hmm what version of wordpress are you using? I tried to replicate your issue on 3.0 and have been unable to do so.

<!-- hidding content like this works just fine -->
h3r2on
+2  A: 

As long as you make sure you're in the HTML view of the post/page editor, you'll be able to enter HTML tags and comments to your heart's content.

To switch to the HTML view, click the HTML tab in the upper right corner of the editing window (next to the Publish fields).

Pat
Nope, that doesn't work. I *am* in HTML view and have lots of other HTML and CSS in there that renders just fine. But for some reason, I see the closing comment tag in the rendered page. The opening comment tag and the block I commented out *do* get hidden, but that closing tag shows up!
+1  A: 

Instead of typeing <!--Comment--> in the editor for your post, Make sure you place the comment tag inside the raw html editor.

alt text

Also use a DOM Inspector to make sure that th --> closing tag is actually coming form the post itself.

Another Tip, before you publish the article, hit the Close Tags button to make sure that it validates your html better.

RobertPitt
I appreciate all the advice. @RobertPitt - Firebug seemed to show that the "-->" got translated to "-->" I tried "close tags" but it didn't seem to help. @h3r2on - I'm using 2.9.2 (can't upgrade to 3 because I've got lots of custom code and not enough time or patience to test/fix)
i know that > gets converted to its enties, but i jsut tested on the latest wordpress version and its ok :/
RobertPitt