WordPress is a really great piece of software but sometimes it fails miserably and you just wonder if none else has had this problem before.
One of these stories is when it comes to display raw code in a WordPress post.
WordPress tries to interpret and execute everything it considers code in a post and makes it hard to display raw code in an uninterpreted form.
So when you are writing a tutorial that includes HTML or PHP code, copy and paste is not a solution. Neither is to put <code></code> around it.
This helps with CSS styling but actually not with the issue of displaying raw code properly.
The encoded code can then be copied and pasted into your WordPress post and voila: It looks exactly as expected once it is posted.