Inline code added to post content disappears or doesn’t execute.
Inline CSS or JavaScript Stripped from Content
Key Points: Your embedded styles/scripts vanish from the frontend or fail to run.
You paste some custom styles or a tracking script in a post… and it’s gone. WordPress has quietly sanitized it for “security,” leaving you confused and scriptless.
🛡️ Why WordPress Does This
- Inline
<style>and<script>tags are often stripped for non-admins - Post content filters apply strict HTML sanitization
- Multisite or user role restrictions block unfiltered HTML
🛠️ Solutions
- Insert critical styles/scripts using
functions.phpor a shortcode - Grant
unfiltered_htmlcapability only to trusted roles - Use a plugin designed to safely embed code (like Insert Headers and Footers)
❗ Reminder
Always sanitize inputs — but if you’re the admin, you can give yourself a little more creative freedom (with caution).