Adanced Custom Fields – TextArea Field Removes Backslashes

WordPressACF is a WordPress great plugin that has so many different applications. It can allow you to easily add extra fields for clients — fields that can be used to do a countless number of things.

It isn’t perfect. There is one minor annoyance that I ran into with it the other day. The textarea fields unfortunately remove backslashes after saving. You can prevent this from happening by using double backslashes, but after you save, the double-backslashes will turn into single-backslashes. What does this mean? If you save again, those single-backslashes are gone once again!

In my case, I was trying to utilize JavaScript that was outputting an alert message that spans multiple lines. To solve that, you can simply replace your newline (“n”) with String.fromCharCode(10).

You may need backslashes for other things though.

In that case, you can edit your plugin, as described here.

Just note that a plugin update can wipe your edit out, so it’s undesirable.

Leave a Reply

Your email address will not be published.