Ready to get started?Download WordPress


Comment out code in HTML view

  1. Michael Madison

    Although you can use "<!-- Some comment -->" to document HTML, you can't use commenting reliably to hide code that includes tags.

    Standard HTML "comment out" functionality is useful when temporarily deactivating code that may be needed later.

    I think there's a workaround, but it shouldn't be necessary.

    Posted: 1 year ago #
  2. Ipstenu (Mika Epstein)

    You shouldn't be using it in posts or comments, though. There's no reason for it.

    Posted: 1 year ago #
  3. Thanks for your reply. I agree that it wouldn't be needed for comments; however, I think there's are powerful reasons for it in posts.

    The problem seems to be that WordPress gets "confused" about where "<!--" is ended. I believe everything between that opening comment tag and the closing "-->" should be ignored.

    In my case, I have many elements on both pages and posts that I sometimes use and sometimes don't. Commenting out HTML code is common practice for some. People using WordPress for its original blogging strength, rather than as a CMS, are probably less likely to be bothered by this.

    Whether this behavior is changed or not will never dim my enthusiasm for WordPress. It ranks among the best choices I've ever made in anything. I'm just passing this along as a suggestion.

    Just to make this clearer: I never use the visual editor at all. It's not even a visible option.

    Posted: 1 year ago #
  4. Ipstenu (Mika Epstein)

    Given that there was recently an exploit revealed by people using mfunc php calls within comments, I would actually see this being stripped :/

    However I feel like I should point out that you're not supposed to be putting a lot of HTML elements in your post content :) Non-Admins can't, for one. Non super-admins can't on a multisite.

    Posted: 1 year ago #
  5. I understand your points and they are valid. And I agree that using HTML in posts is dangerous, if many people are adding to the site.

    But my site doesn't have editors or outside contributors. And I'm guessing there are others like me in that regard.

    Posts and pages are major means of showcasing elaborate content. Calls to PHP are another. In any case, since there is an HTML editor, I can state that -- for me -- being able to comment out code temporarily and leaving it for possible future use is a feature I would like.

    Still, I can see where you're coming from. My main point is that, whether commenting out code (or even adding HTML elements) is good or bad, it is permitted. So, the ability to occasionally comment it out, as is common practice in other environments, would be useful. I can work around it by saving code and reinserting or, in some cases, by simply switching to "display: none;" from "display: inline;".

    So, on reflection, if this doesn't seem like a good feature to WordPress developers or if it is considered outside the community intent, then there are more important things to focus on, and I withdraw my request. Thanks for considering this.

    Posted: 1 year ago #
  6. i think there is a good reason to have hidden text in posts as an option maybe the html comment out code isn't the way (although I'm not sure what would be if that wasn't) for instance if you plan on having revisions to a page or have parts of the page/post which are only applicable in certain date ranges but you don't want to have to erase and then re-type the content a comment out functionality would be quite useful.

    just saying…


    Posted: 4 weeks ago #

RSS feed for this topic


You must log in to post.

  • Rating

    0 Votes
  • Status

    Sorry, not right now