There’s a bit of a problem with previewing posts in WordPress. Here’s a code snippet you can use in your plugins or themes to get around the problem.