Preserve formatting of code for display by preventing its modification by WordPress and other plugins while also retaining whitespace.
As of April 2026, Preserve Code Formatting is a WordPress code plugin with 400 active installations and a 4.7/5 rating from 3 reviews. It has been downloaded 49K+ times in total. Requires WordPress 5.5+ and PHP false+. Available on WordPress.org since 2005. Top alternative: WPCode – Insert Headers and Footers +….
This plugin preserves formatting of code for display by preventing its modification by WordPress and other plugins while also retaining whitespace.
NOTE: This plugin does NOT handle posts containing blocks. For such posts, use the built-in code or preformatted blocks to format your code for display. However, this plugin would still be needed if you have text-based posts from before using the blocks-based editor.
NOTE: Use of the visual text editor will pose problems as it can mangle your intent in terms of code tags. I strongly suggest you not use the visual editor in conjunction with this plugin as I have taken no effort to make the two compatible.
Notes:
Basically, you can just paste code into code, pre, and/or other tags you additionally specify and this plugin will:
| WordPress | 5.5+ requiredTested up to 6.8.5 |
| PHP | false+ required |
Highlights:
This major release significantly improves security, performance, and compatibility. The plugin framework updates to version 070 for enhanced security and features. Block editor content is now properly excluded (the plugin was designed for text view), and compatibility extends through WordPress 6.8+ while dropping support for versions older than 5.5. Additional improvements include better error handling, enhanced documentation, and the addition of CSS classes for styling processed code blocks.
Details:
…and 29 more changes
Plugin data sourced from WordPress.org. Analysis and metrics by PluginSift.