Shahriar Kabir

Software Engineer

MCPD

OCJP

MCSE

Shahriar Kabir

Software Engineer

MCPD

OCJP

MCSE

Blog Post

How to Fix the Parse Error, Syntax Error, Unexpected in WordPress

February 17, 2022 WordPress
How to Fix the Parse Error, Syntax Error, Unexpected in WordPress

Parse Error , Syntax Error – While many of the errors we’ll be looking at can be frustrating due to how little information they give you, the ‘parse error’ (or ‘syntax error’) is at least helpful enough to tell you exactly what’s wrong.

Parse error syntax error unexpected end in WordPress can be the simplest of errors and still cause a big problem.

The error has two parts:

Syntax Error – This error is caused by an error in the PHP structure when a character is missing or added that shouldn’t be there.

Unexpected – This means the code is missing a character and PHP reaches the end of the file without finding what it’s looking for. The error will include information at the end that explains what it saw that was unexpected.

If you see Parse Error, Syntax Error, Unexpected end in WordPress, it just means that WordPress detected that something in the code is missing or added. It can be something as simple as a comma, semi-colon, a closing parenthesis, or one too many brackets.

The missing syntax can be within code that you’ve written or pasted into your website, or within a theme or plugin that you’ve installed or updated.

Fortunately, it’s not that difficult to find and fix. However, you will need to understand how code works and how to edit it.

How to Solve Parse Error,  Syntax Error Unexpected End in WordPress

Parse Error

This error occurs when there is an issue with your site’s code, most commonly in the functions.php file. Instead of loading your page, a simple message will appear, which explains what the issue is and where it occurred.

To fix the problem, you’ll need to access the specified file using SFTP. We’ll be using FileZilla, as it’s a free and open-source tool. Just use the SFTP credentials provided by your web host, and access your site’s backend.

Then, you need to find the file in question. In the example pictured above, you can see that the problem is in the functions.php file for the site’s current theme. As such, we’ll access that theme’s folder, right-click on functions.php, and select View/Edit.

Parse Error

If you check the Parse error message, you can see that it even tells you on what line the problem exists. Now we just need to find that line and fix the problem. In our example, it’s a simple case of a missing parenthesis, so let’s sort that out.

Parse Error

Save your file, and select Yes when your FTP client asks if you want to replace the existing file on the server. You should now be able to check your site and see that it’s back to normal.

Related posts:

Write a comment