WordPress Parse Error: Syntax Error in functions.php
Critical Frequency: CommonError message:
Parse error: syntax error, unexpected tokenA parse error in functions.php completely breaks your site because WordPress loads this file on every page request. If there’s a syntax error, PHP can’t parse the file, and the entire site goes down.
This is why you should never edit theme files through the WordPress admin editor. If you introduce a syntax error, you’ll lock yourself out of the admin dashboard too.
Common Causes
- Missing semicolon, bracket, or quote in functions.php
- Copying code from a website that uses curly quotes instead of straight quotes
- PHP version incompatibility (using ?> short tags, match expressions, etc.)
- Editing theme files from the WordPress admin without a safety net
- Pasting code with invisible characters (BOM, zero-width spaces)
How to Fix It
- Use FTP/SSH to edit the file: Open
wp-content/themes/your-theme/functions.phpand fix or remove the problematic code - Revert to backup: If you have a backup, restore the previous functions.php
- Switch themes via database: Run
wp option update template twentytwentyfourandwp option update stylesheet twentytwentyfour - Use a proper code editor with syntax highlighting u2014 never edit PHP in the WordPress admin
- Install the Code Snippets plugin to add PHP code safely (it catches parse errors before saving)
Frequently Asked Questions
I edited functions.php and now my site is broken. How do I fix it?
Use FTP or SSH to access wp-content/themes/your-theme/functions.php. Either fix the syntax error or delete the code you added. The site will immediately come back.
How can I safely add code to WordPress?
Use the Code Snippets plugin, a child theme, or a custom mu-plugin. Never edit theme files through the WordPress admin editor. Always use a code editor with syntax highlighting.
Get WordPress Performance Tips
Plugin reviews, speed optimization guides, and error debugging — straight to your inbox.
No spam. Unsubscribe anytime. We respect your privacy.