New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

Parse error

Learn how to fix a WordPress parse error or syntax error.

Parse error syntax error unexpected means PHP found invalid code before WordPress could run. It usually happens after editing functions.php, a snippet plugin, or a corrupted upload. This tutorial shows how to find and fix the broken file fast.

Time: 10-25 minutes Level: Intermediate
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

What this problem looks like

Unlike vague critical errors, parse errors name the exact file and line. Common causes include a missing semicolon, unclosed bracket, pasted code outside PHP tags, or a bad edit to functions.php from the theme customiser.

You do not need wp-admin to fix this. Open the file via File Manager, SFTP, or FTP, correct or remove the bad code, and reload the site.

Step 1: Decode the error message

A typical message looks like: Parse error: syntax error, unexpected end of file in /home/user/public_html/wp-content/themes/mytheme/functions.php on line 42. The path and line number are your map.

  • functions.php in your theme: undo recent custom code.
  • wp-content/plugins/code-snippets/: deactivate the snippet plugin via File Manager, SFTP, or FTP.
  • mu-plugins/: remove the offending must-use plugin file.

Step 2: Fix functions.php safely

Open wp-content/themes/your-theme/functions.php. Go to the line in the error. Look for unclosed {, (, or missing ;. If you are unsure, comment out the recent block by wrapping it:

php
/*
Your recent custom code here
*/

Step 3: Deactivate snippet and custom code plugins

If the path is inside wp-content/plugins/, rename that plugin folder to .off via File Manager, SFTP, or FTP. Code Snippets, Insert Headers and Footers, and WPCode are frequent sources of parse errors after quick edits.

Step 4: Restore the original file

Download a fresh copy of the theme or plugin from the vendor ZIP and replace only the broken PHP file. Do not overwrite wp-config.php or uploads.

Step 5: Validate PHP before saving next time

If you have SSH access, run php -l against a file before upload. This command will not work inside File Manager.

bash
php -l wp-content/themes/mytheme/functions.php

When to stop DIY and hire help

If the parse error points at WordPress core files you did not edit, files may be corrupted or infected. BugShield fixes syntax and core corruption at a confirmed price without hourly billing surprises.

Questions answered

WordPress parse error and syntax error FAQs

Answers about reading PHP syntax messages, reversing unsafe edits, and restoring WordPress when wp-admin will not open.

Can I fix a parse error without wp-admin?

Yes. Parse errors are fixed by editing the named file via File Manager, SFTP, or FTP. Admin is not required.

Why did this happen after a theme update?

Custom code in a parent theme functions.php is overwritten or merged badly. Use a child theme for custom PHP.

What if the error says unexpected T_STRING?

Usually a missing semicolon or quote on the line above the one shown. PHP line numbers can point one line after the real mistake.

Should I reinstall WordPress core for parse errors?

Only if the error path is in wp-includes/ or wp-admin/ and you did not edit those files. Otherwise fix the named plugin or theme file.

What causes a WordPress parse error or syntax error?

PHP found code it could not understand, often after a manual edit, incomplete update, damaged upload, incompatible plugin, or missing bracket, quote, or semicolon.

How do I use the file and line number in a WordPress parse error?

Open the named file through your host or SFTP and inspect the stated line plus the lines immediately above it, where an unclosed quote or bracket often begins.

Should I edit the broken PHP file directly on the live site?

Only to reverse a known recent change when you have a backup. For unfamiliar code, replace it from a clean package or test the correction on staging.

Can a PHP version change trigger WordPress syntax errors?

Yes. Older code may use syntax removed by a newer PHP release. A temporary version switch can confirm this, but the code still needs updating or replacing.

How do I fix a parse error caused by a plugin or theme update?

Rename the affected extension folder to restore access, then reinstall a clean compatible release or roll back to the last known working version.

When should a developer fix a WordPress syntax error?

Get help when the file contains custom code, the reported line is not the real source, or correcting it could overwrite business-specific theme or plugin work.

Would you rather a developer fixed it?

Request a fix at a confirmed price and speak directly with the BugShield developer working on your site.

Request a Fix