Escape HTML in WordPress

This sounds a little silly, but even as a developer I briefly got confused while trying to render (or rather, not render) HTML in WordPress.

I typically dump code into WordPress using their markdown syntax, which works great for almost everything.  But if you need to actually put HTML in a code block, that fails because it will literally get rendered into the page!

The solution is easy though.  Just google “HTML Entity Encoder” or something similar and you’ll get to a site like this https://mothereff.in/html-entities where you can enter your HTML and have it encoded so that it will display properly.

In case that doesn’t make sense to you, let’s use a div opening tag as an example.  It would change to &lt;div&gt; where the “lt” is less-than, or “<“, and the “rt” is greater-than, or “>”.  Since it’s encoded, it will be displayed properly, but the div tag will not be interpreted part of the page.