How to Fix Syntax Error in WordPress?

This error usually occurs when you are trying to add code snippets into WordPress and have accidentally missed something or the code has incorrect syntax. This will result into a PHP parse error and you will see a notice like:

Parse error- syntax error, unexpected $end in /public_html/site1/wp-content/themes/my-theme/functions.php on line 278

The error message would indicate the unexpected thing found in the code and the location of the script where the error occurred with line number. To fix this issue you will have to correct the syntax. Most of the time it is a missing bracket or some unexpected character in the code. In this article we will show you how to fix the unexpected syntax error in WordPress.

Video Tutorial #

If you don’t like the video or need more instructions, then continue reading.

Fixing the Syntax Error Using FTP #

In order to fix the Syntax Error, you need to edit the code that caused this error. You can either remove it or fix the syntax. Often beginners freak out because this error causes your entire site to become inaccessible. If you pasted the code using your WordPress dashboard Appearance » Editor section, then you are locked out. So how do you edit the code? Check out our guide on locked out of WordPress admin. The only way to fix this is to access the file you last edited using FTP (How to use FTP).

After installing the FTP program, connect it to your website and go to the theme file that needs editing. In case you forgot which file you need to edit, just look at the error code. The error will tell you exactly which file and which line you need to edit.

You can either remove the code you last added or write the code in correct syntax. Once you are done removing / editing the code, save the file and upload it back to your server. Come to your WordPress site and refresh the page, and your site will be working.

We hope this article helped you fix Syntax Error in WordPress. Please leave your questions and feedback in the comments.

This article was originally published on WPBeginner.com

We use cookies to improve your experience on our website. By browsing this website, you agree to use of cookies by this website.
Accept More info