How to Fix Parse Error: Syntax Error in WordPress

Although phase error or a syntax error is a minor error, it can cause the whole site to break. WordPress users who regularly work with codes must be familiar with this error. But for new users who are seeing this error for the first time, it may look scary. Do not panic because it is not a big error and few simple steps can solve the problem. In this article, we will show you just the right and simple way to fix parse error: syntax error in WordPress.

How to Fix Parse Error: Syntax Error in WordPress

What causes parse error?

These errors occur due to many reasons. Here is a list of a few reasons. The primary cause of this error is when a snippet of code is incorrect within a theme file or a character or tag is in the wrong place or it’s missing altogether. This error can be minor like missing a comma or adding an extra bracket in the code. Maybe you had recently copied a snippet from the web or updated a plugin.

The other rare causes of this can be the corrupt database or the incompatible version of PHP in your WordPress. Sometimes the file permission issue and exhaustion of PHP memory in the server can also give rise to the parse errors.

Fixing the errors

If you are a programmer and enjoy working with codes, this error should not bother you. But if you are seeing this error for the first time then here are the possible solutions you can try. The first step of the solution is to read the error instruction correctly. Here is what my syntax error looks like.

The error message is clearly telling that functions.php file in my twentyseventeen theme has an error in line 17. Remember your error message will be different than mine but the solution is somewhat similar. Since parse error will lock you out of the WordPress dashboard access, you have to find a way to access the specific file.

How to Use FTP to access the server files?

FTP stands for File Transfer Protocol. It is used to access the files in web server. To connect to FTP server you need some FTP details. Learning to use FTP can save you from many kinds of troubles. If you don’t have FTP username and password it is better if you set one up. The best thing you can do is contact your hosting company for help.

In order to transfer files to your server, you will need to download an FTP client to your computer. One of the most popular FTP clients is FileZilla. FileZilla can be downloaded for Windows, Linux, and Mac from the FiIeZilla website.

After installing FileZilla on your computer, you can open the software and start connecting to the FTP server for file transfer. To connect to the FTP server you have to enter the FTP information that you collected earlier. You can use the Quickconnect bar situated just after the toolbar menu. Enter your host name. Enter the port number (21 for FTP and 22 for SFTP). Generally, for username/password, the anonymous login will be used. If username/password is required then enter your specific username and password. Finally, click the Quickconnect button to start the connection.

Once you are connected you will have access to the folders of your website. On the right-hand side of the window, you will see the folder structure of your website. The left side the window shows the local folders structure from your computer.

Also Read:   The 7 Deadly Sins Which Beginner WordPress Developers Make

Troubleshooting the file that is creating the parse error

If you read the error message once again you can clearly find out the specific file and even the line number where the error exists. All you have to do is download the specific file using Filezilla and edit the code locally on your computer and upload it back to the server.

Let’s see an example. In my case, the error exists in functions.php file of the twentyseventeen theme on line number 17. Now let’s use FileZilla to navigate to the functions.php file present in the remote folder structure. On the right side of the window, let’s download the corrupt file from the remote site. To download any files navigate to the file and right click and then click download. The files will be downloaded to the local computer in the location of your right side window.

Now simply open the downloaded file with notepad++ or any file editor. I am using file editor called Sublime Text. In my case, I go to line number 17 and delete the extra bracket.

If you have recently copied any code from the tutorials you can delete it from the file. On the specific line number, you might have overwritten an extra character or might have missed anything. Check and correct the error. Once the error is corrected, do not forget to save the file. Now finally we need to upload the corrected file to the server and replace the old corrupt file. To upload, locate the file in the left window and then upload it by right clicking. You can also drag and drop the file from left window to the right window. Make sure you upload the file in the exact same location from where you had downloaded it. Obviously, you will see a message box saying target file already exists. Simply overwrite the old file.

FTP upload - Fix Parse Error: Syntax Error in WordPress

Now if you check back your website, and refresh the page your website should be working fine. In this article, we discussed how can we fix parse error: syntax error in WordPress. You can also read our other articles on various troubleshooting topics.

How to Fix 500 Internal Server Error in WordPress

Fix Error Establishing Database Connection in WordPress

Fix Fatal Error: Maximum execution time of 30 seconds exceeded

The following two tabs change content below.

Kantiman Bajracharya

Kantiman Bajracharya is a freelance web developer. He is a computer geek who has a Bachelor’s degree in Computer Engineering. He has earned lots of satisfied customers while working for numerous successful projects. He is also a WordPress theme creator and web article writer. On free time he likes reading philosophy books, traveling and playing chess.

Share This Post