How to Fix the Syntax Error in WordPress

syntax-error-in-wordpress-smart-active-blogger

No other CMS provides that many option like wordpress does, and that makes it easier for everyone to experiment and make the customizations to whatever they want.

But customization doesn’t provide the expected results everytime, and when it doesn’t it ends with some unexpected syntax errors.

So If you were trying something new on your WordPress site and got a following error message “Syntax error, unexpected…

In this article I will show you how to fix the unexpected syntax error in WordPress.

Using Proper Syntax to Avoid Errors

how-to-fix-syntax-error-in-wordpress

 

Most of the syntax errors occur due to tiny errors that most people forget or don’t care about. Most of them are the comma, semicolon or a curly brace at the end.

Did you recently paste a snippet from the web? Updated a plugin? Then chances are you know exactly where to look.

Since most people are not developers and they copy codes from the internet and blogs and directly paste them in their files and mentioned in that blog.

So if you hit the Parse Error – Syntax error, Unexpected error in WordPress then here is what you can do.

  1. You can just delete or comment out the code you recently pasted that resulted in syntax error
  2. Find the error and fix it, Since most people are not developers and don’t know how to code, so this process may be the tough one
  3. The best way, visit your WordPress root folder and access your error_log in your cPanel. Analyse and read your WordPress error_log, since error log shows the exact problem that caused the error.

 

The 3rd option is the best way to know the problem, but the question is not just knowing about the problem, its about fixing the problem too. Most of the time when and user edit or paste some code they do it through the wordpress dashboard > editor and if they hit the syntax error then they are locked out of the wordpress dashboard.

So if in case you are locked out of the wordpress dashboard you can fix this problem using FTP.

Fixing the Syntax Error Using FTP

In order to fix the Syntax Error through FTP you need to edit the code that caused this error. Often beginners freak out because this error causes your entire site to become inaccessible and you are locked out of your wordpress admin area.

After installing the FTP program, connect it to your website and go to the required file that needs editing (i.e: the file you were editing through your wordpress editor).

In case you forgot which file you need to edit, just look at the error_log or the error code. The error_log and error code 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 or just comment it out. Once you are done removing / commenting / 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. I am always free and eager to help people.

Summary
Article Name
How to Fix the Syntax Error in WordPress
Author
Smart Active Blogger

Author: EDITORIAL STAFF

Editorial Staff at SmartActiveBlogger is a team of WordPress experts led by Niraj Kashyap. Page maintained by Niraj Kashyap.