Is It Possible to Comment Out HTML Code in a Wordpress Post?

Is It Possible to Comment Out HTML Code in a Wordpress Post?

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?


Can anybody send me links of some good tutorial about wordpress development [closed]


BuddyPress slug prefix
wpautop() contains a bug that breaks comments containing HTML code.

Removing href from dynamic item?
An easy workaround is to add a second opening HTML comment tag just before the closing - this tricks WordPress into working like you would expect it to.

wordpress - unique theme for different pages
Very strange problem with Wordpress Blog
This will work in WordPress:.
Choosing the main category for a post in Wordpress
<!-- <div class="book floatleft"><a href="#"> <img src="" alt="" /> </a></div> <!-- --> 
This will not work in WordPress:.
Wordpress: Display Total Number of Posts For Current Month, Week and Day?
<!-- <div class="book floatleft"><a href="#"> <img src="" alt="" /> </a></div> --> 

WordPress Visual Editor - Indent Button and Unordered Lists


Use a hidden div block. like this:.
<div style="display: none;">  ...comment... 

works like a charm.


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


You could try one of the following plugins which preserves code formatting within the html editor:.
  • TRUEedit Plugin
  • WP Super Edit
  • ps-disable-auto-formatting
  • Unfiltered MU (multisite only)
I believe most of these plugins removes the wptexturize filter that WordPress uses which replaces characters and patterns (which messes up some shortcodes and html).. If your using 'Deans FCKEditor' or 'Foliopress WYSIWYG' that could be the problem since they convert quotes to html quotes, add paragraph markup, mess up shortcodes, and do some other html character replacement..


This snippet should do what you're looking for..
// Add the unfiltered_html capability back in to WordPress 3.0 multisite. 

function um_unfilter_multisite( $caps, $cap, $user_id, $args ) { if ( $cap == 'unfiltered_html' ) { unset( $caps ); $caps[] = $cap; } return $caps; } add_filter( 'map_meta_cap', 'um_unfilter_multisite', 10, 4 );


Try this:.
<!-- Comment --!> 
Works like a charm..


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


Try this:.
&lt;!&#45;&#45;<br /> ... 

commented out stuff ...<br > &lt;&#45;&#45;&gt;
but beware the HTML break tag WordPress will throw in at the end of the comment..


Like jharrel suggested, this works just fine:.
<!-- content <!-- --> 

70 out of 100 based on 55 user ratings 1230 reviews