How to Comment Out Code in WordPress

How to Comment Out Code in WordPress

Here is a basic tip for working with WordPress files. “Commenting out” code is a way making a section or block of code inactive. It can be handy, because there are times when you may want to temporarily comment code out but leave it in there so that you can use it later. It essentially hides the code until you remove the comment code.

Depending on what type of file you’re working in, there are different bits of code you’ll need to use. These examples are taken directly from the WordPress codex:

To comment out HTML:
{code type=php}{/code}

CSS file example:
{code type=css}/* .redblock {font-size: 80%; font-style: italic; color: red; } */{/code}

Within PHP tags:
{code type=php}{/code}
or
{code type=php}{/code}

This is a very basic skill that you will want to have under your belt when working with WordPress files. For more information about commenting code, please refer to the WordPress codex.