Displaying Backslashes (And Other Non-Displayable Characters) in WordPress
The other day I ran into a problem while writing a post to one of my WordPress blogs. I needed to use a backslash character (\) but it wouldn’t appear when I viewed the post. Though this character is saved in the database and displayed on the backend when editing the post it is not displayed on the front end when viewing the post.
It turns out that the backslash character is one of many characters that shows this behavior. I’m not quite sure why but one of the web pages I came across when researching the issue suggested it’s a security issue.
But I found a solution. Instead of using the actual backslash character use the HTML escape character & #92; (with no space after the &, I added the space for display purposes) instead. There’s an HTML escape character for any character you may use in a blog post so if your blog post is missing characters just try to replace that character with it’s equivalent escape character. For a complete list of HTML escape characters go here.
Caveat: this needs to be done in the HTML editor. It will not work properly in the visual editor. Switching between the HTML and visual editors without saving the post or saving from the visual editor could overwrite the escape character in the database and render the fix useless.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.