WordPress.org

Ready to get started?Download WordPress

Forums

hide Comments in HTML? (7 posts)

  1. arthurdent2003
    Member
    Posted 3 years ago #

    Hi!

    I'd like to hide all comments I've made in the HTML/PHP files when the site shows up in the front end. Any idea to make it with functions.php? I tried wp-minify...but somehow it cracks my backend....

    At the moment it looks like this:

    </head>`
    <!-- a good place to work on in the future --><div =.....`

    thank you!

    AD

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Simply convert all of your comments to PHP comments, which are stripped by the PHP parser when serving the rendered page output.

  3. arthurdent2003
    Member
    Posted 3 years ago #

    Hi Chip,
    thanks for the reply!

    I tried it...but when I write:` </head>
    /* a good place to work on in the future */<div =..... `

    it still appears....

    thank you!

    AD

  4. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Did you put your PHP comments inside of PHP tags?

    This will output in rendered HTML:

    /* a good place to work on in the future */

    This will not:

    <?php /* a good place to work on in the future */ ?>
  5. arthurdent2003
    Member
    Posted 3 years ago #

    Ah! yes - now I got it! :-) thank you!

    I forgot to set the <? php ---- ?> stuff around it.

    That works now...but I still have tons of <!-- --> comments in the html code from plugins and so on. Is there any way to just say somethging like: "kill everything with <!-- --> around?"

    thank you!

    AD

  6. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    That works now...but I still have tons of <!-- --> comments in the html code from plugins and so on. Is there any way to just say somethging like: "kill everything with <!-- --> around?"

    Not really. You'd have to figure out how the Plugins are injecting those comments. If they're using filters, you could override the filter. Otherwise, you would have to edit the Plugin code to strip the HTML comments.

  7. arthurdent2003
    Member
    Posted 3 years ago #

    ok - thank you...it works with wp-minify...but this plugin also makes thumbnails in articles or custom posts disappear....

    well - thank you so far, chip!

    AD

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags