WordPress.org

Ready to get started?Download WordPress

Ideas

Comment out code in HTML view

  1. Michael Madison
    Member

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

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

    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 #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    0 Votes
  • Status

    Sorry, not right now