Today I had the opportunity to help a new client fix a syntax error in WordPress. If you are seeing the same error instead of your website, then here is how you can get your site up.

A syntax error or a parse error as it is sometimes called is a notice that something is wrong with a line of code in a website. This could be in either your theme, plugin or WordPress files.

WordPress is built using PHP, a programming language that by no means tries to guess the intentions of the programmer. So it will throw an error if it finds something strange or missing in the code as it is run/compiled/parsed.

Often such errors are human, for instance when a programmer is sloppy to leave unclosed quotes, misses or adds extra parentheses, misses a semicolon or a simple spelling error.

Because PHP is rigid in its rules, it will stop at the point where the parser encounters an error and gives up.

This error is then displayed on a browser showing the file, and the line number on the code – the point at which the parser finds the error.

This makes it easy to troubleshoot the syntax error.  In the error below, for instance, you can see that there is an unexpected text in the code in class-oembed.php on line 421.

Syntax Error

Beginners Guide: How to Fix the Syntax Error in WordPress Using 2 methods?

If you are aware of ongoing work or if you have a support agreement with the person who built your website, then contact them. They will appreciate the thought if you share this article with them.

For the rest of us, let’s move on.

When troubleshooting syntax errors, I always look at what files are affected. Is it the theme or a plugin or is it the WordPress core files. Most times for core WordPress files and plugins I reupload new files.

If the error is related to your theme, or if you were editing something else, then you will need to access the server where the files sit.

If the website is remotely hosted, you will need an FTP client or access the file manager of your host. 

Method 1 – Fix the Syntax Error with an FTP client.

If you prefer to use an FTP client, FileZilla and Core FTP for windows and Cyberduck for Mac are formidable free options.

Download, Install, and launch the program.

You will need the Host address, Username, Password and the port number (21).

If you don’t know these, contact your host or look for one of the emails sent to you when you bought your hosting account.

If you use FileZilla, supply the required information and then click Quickconnect.

Filezilla Quickconnect

Once you log in, navigate to the folder containing the file shown on the error message. In my case it was /public_html/wp-includes.

You can right-click and then click View/Edit to edit it or download it. I always opt to download the file to the computer so I can make a copy of it before making any changes.

Edit Synax error folder via Filezilla

With the file saved to your computer.

Download, install, and run a code editor like SublimeText or Visual Studio Code. Any other IDE or editor for PHP with syntax highlighting will work.

Open the file you downloaded and scroll to the line number. In my case, it is in line 421.

If you saw the error after modifying code, check for anything strange, could it be a missing bracket, tag, or semicolon?

If that line looks fine, look at the previous lines of code. The line number shown is only where the parse gave up, the error could be on the last line. Check, for likely culprits.

Edit it and save. Then upload the file.

Modify error code in editor

Reload your website.

Method 2 – Fix the Syntax Error within the host’s File Manager.

Now, that was editing the file with an FTP client. You can also select the file in your host’s control panel.

Navigate to the folder containing the file shown on the error message. In my case it was /public_html/wp-includes.

Then, right-click the file. Click Edit.

Fix the Syntax Error with cPanel

Scroll down the line in question. The cPanel code editor will show the exact place where the code breaks.

Go ahead and make changes.

Edit broken code via cPanel

After you save your change, reload the website. It should be back.

If it is not, clear the cache on your browser or on WordPress and try again.


It turns out my new client’s site was hacked into. I replaced all the WordPress files with a fresh copy. Voila, everything worked.

If you are at fault for the error, then you will want to consider using use proper code indentation alongside an  IDE or editor for PHP with syntax highlighting for coding. It is a savior.

Finally, this should bring you to notice that anything can happen to your website. Hackers, human error, or a bizarre lightning strike and you are wiped off the internet.

So, learn to maintain backups for your website. We built an excellent plugin for that, WPVivid backup and restore plugin. Try it.