I think many people have problem when inserting code in their WordPress posts or comments. For example   if you are developer or if you have found some interesting code in the Internet and want to share it with your readers then most likely you will meet some difficulties.

If you just copy and paste code in its original form into your post it will try to work like a real program and will execute its  commands. By default WordPress will convert it and as a result you will receive unpredictable results like strange pages or  missing symbols in your code or it may just disappear.

In order to publish the code into a post it must be converted to a text suitable for publication. It could be made by hand with replacing the following characters with their substitutes.

”       =   "
&     =    &
<     =     <
>     =     >

But there is an easier way to do this using one of the following online converters.

CENTRICLE

POSTABLE

Go to one of  the above sites and paste your code to the empty field. Then click on Encode and you will have new converted code ready for posting.

Note: When inserting your code use HTML mode of  WordPress editor  not Visual .

Now place <code> and </code>   in your post and paste converted code between these tags. This method worked for me.

Good luck.