If you are a new to WordPress and trying different things out in WordPress then you may get an error like Syntax error, unexpected…, Don’t worry, you are not the only one who gets this syntax error, most beginners are facing it. In this article, we are going to solve this problem of unexpected error in WordPress. First, have a look at WordPress syntax error(Screenshot below)
The reason is, you may have missed a single bracket, a comma or you have made some crucial mistakes in your code syntax. We are going to solve this problem; because this tiny syntax error can break the entire script aka your WordPress site.
Fixing the Syntax Error using FTP
As we know that syntax error occurs due to a mistake in code and if you want to fix the syntax error you need to edit the specific code. Often people get tensed because due to this error they can not access their entire website. If you pasted the code using your WordPress dashboard you are locked out there.
The only way to solve this, you have to access the file you last edited using FTP. The error in above screenshot display the file path and the line number with the issue.
Enable Debug Mode
Make sure the WP_DEBUG is set to true in wp-config.php at your site. If not, add the following code before the comment /* Thats all … */ in wp-config.php in your root directory.
define( 'WP_DEBUG', true );
Through Control Panel
You can fix the syntax error through your cPanel too. You have to follow these steps:
- Login to your cPanel
- Find file manager
- Enable debug mode
- Edit the file
- Click on save button
That’s all, now you can access your website again.
I hope this article helped you in fixing the syntax error. Kindly leave your questions in the comment section.