Tutorials for web designers and developers
Tutorials for Developers_
Close this search box.
Shabnam Rafique Bajwa

Shabnam Rafique Bajwa

Shabnam Rafique Bajwa is working as a Content writer at HFarazm. Her educational background is in Software Engineering from the University of Lahore and Masters in Software Engineering from Superior University.
syntax error

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)

syntax error

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 );

To solve this issue, access your site through FTP and open the exact file with the error (as shown in error with line number). If you forget the file just have a look at the error code, the error will tell you the exact file and line you need to edit. Open the file and edit the code or correct the syntax. When you find the error and remove it just save the file and upload it back to your server. Just go and refresh your site. It will work properly.

Through Control Panel

You can fix the syntax error through your cPanel too. You have to follow these steps:

  1. Login to your cPanel
  2. Find file manager
  3. Enable debug mode
  4. Edit the file
  5. 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.


Leave a Reply

Your email address will not be published. Required fields are marked *