WordPress Parse Error: Syntax Error, Unexpected … How to Fix It (2026)
A parse error means PHP found a mistake in the structure of your code, usually after you edited functions.php or pasted a snippet. The message names the file and an approximate line. Undo that last edit by FTP, or restore the original file, and the site comes back.
The error looks like “Parse error: syntax error, unexpected …” and often takes the whole site down. Because it points to a specific file, it is one of the easier WordPress errors to fix if you know how to read it.
What a Parse or Syntax Error Is
The WordPress handbook says a syntax error means you made a mistake in your PHP structure. It gives examples: a missing semicolon at the end of a line, curly quotation marks used instead of straight ones, or a missing curly bracket. The error tells you which file it is in, for example functions.php, and approximately which line. The handbook warns the line number may not be exact, so check just before and just after it.
Quick Diagnosis
| Message | What it usually means (per the handbook) |
|---|---|
| unexpected ‘=’ | A $ was left off a variable |
| unexpected ‘)’ | The opening bracket ( is missing |
| unexpected ‘(‘ | The closing bracket ) is missing |
| unexpected T_STRING | A quotation mark or semicolon is missing at the end of the previous line |
| unexpected T_ELSE | An else statement has no opening if statement |
| use of an undefined constant | A $ is missing, or array keys have no quotation marks |
Before You Start
You need FTP or your host’s file manager, because the dashboard is usually unreachable. Download a copy of the broken file before you change it.
Fix 1: Undo Your Last Edit
If you just edited a theme file or pasted a snippet, remove or fix that change. Open the file named in the error, go to the line it points to, and check the lines just before and after. Look for the problems in the table above, and for curly quotes copied from a web page. If you have a backup of the file, restore it.
Fix 2: Deactivate the Plugin or Theme
If the error names a file inside wp-content/plugins, rename that plugin’s folder through FTP to deactivate it. If it names a theme file, rename the theme folder so WordPress falls back to a default theme. This is the same method as in our critical error guide. Then update the plugin or contact its author, with the exact error text.
Fix 3: Replace the File With a Clean Copy
For a core file, download a fresh WordPress package and copy the original file. For a plugin or theme, reinstall it from its official source. Do not overwrite wp-config.php or wp-content as a whole.
How to Prevent It
- Edit code on a staging copy, not on the live site.
- Use a code snippets plugin or a child theme instead of editing the main theme file directly.
- Copy code as plain text so curly quotes do not slip in.
If the page is blank instead of showing a message, see the white screen of death guide.
Verified Facts and Sources
The meaning of each unexpected message and the common causes come from the PHP errors section of the WordPress handbook. We did not trigger a parse error on a test site for this article.
Frequently Asked Questions
What causes a WordPress parse error?
A mistake in PHP code structure, such as a missing semicolon, a missing bracket or curly quotes, usually after a code edit.
Is the line number in the error exact?
Not always. The handbook says to check the lines just before and after it.
Will I lose content?
No. The error is in a code file, not in your database. Still, back up before you change files.
How do I fix it if I cannot log in?
Use FTP or your host’s file manager to undo the edit, or rename the plugin or theme folder named in the error.
Updated December 2, 2026.