There are quite a few ways that source code and other preformatted text can get mangled in WordPress, such as a rich-text editor, or even by the export/import process.
When I speak of ‘mangled’, I mean unnecessarily HTML-encoded. Left and right angle brackets (the < and > signs), quotation marks (the ” symbol), and ampersands (the & symbol) get HTML-encoded to <, &rt;, ", and &. This can seriously mangle sourcecode, as well as making other text seriously ugly.
It can become a huge time waste to try to go back and edit all your affected posts one at a time to fix mangled code, even with search-and-replace.
Instead, there’s an easy and straight-forward way to do it in SQL, that you can execute from phpMyAdmin, MySQL Workbench, or whatever you fancy.
Simply run each of the following queries on your WordPress database, and feel free to edit them as you like.
update wp_posts set post_content = replace(post_content, '"', '"'); update wp_posts set post_content = replace(post_content, '>', '>'); update wp_posts set post_content = replace(post_content, '<', '<');
Have any others to suggest? Please feel free to do so in the comments below. Thanks!