Preserving backslashes in post_content
I am trying to preserve backslahes in post_content. When I escape the content with another backslash, it gets saved into the database correctly. However the next time I load the page in admin to edit it, the backslash is unescaped. So when I save the page after edits, it disappears as PHP thinks I am trying to escape the character after it.
Example: \\something
in page gets saved as \something
in the database. The next time I load the page in admin, there's only \something
(that's what's saved in the DB). If I save the page now, the backslash disappears and only something
is saved.
I have tried save_post
and content_save_pre
hooks to manually add another backslash to escape my backslash. For some reason str_replace()
worked for only the first few hundred characters of post_content.
Do you please have any better way to preserve backslashes without having to manually escape all of them when saving a page after editing?