Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Fix the Syntax Error in WordPress

Last updated on by
Follow WPBeginner on YouTube
How to Fix the Syntax Error in WordPress

There is such an abundance of WordPress tutorials, guides, and code snippets available on the web. They are all intended for users to try new things on their website and learn more about WordPress. Sadly a small little error can cause the whole site to break which is very scary specially for new users. If you were trying something new on your WordPress site and got a following error “Syntax error, unexpected…”, then don’t freak out. You are not the first one to receive the syntax error in WordPress, and you will not be the last one. In this article we will show you how to fix the unexpected syntax error in WordPress.

Using Proper Syntax to Avoid Errors

Syntax error in WordPress

First thing you need to do is to look at the beginner’s guide to pasting snippets from the web into WordPress. This article lists some very common mistakes made by beginners when pasting code in WordPress templates. The syntax error is usually caused by a tiny but crucial mistake in your code syntax. A missing comma, or an extra curly bracket can break the entire script.

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

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.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • http://www.wpbeginner.com/ WPBeginner Staff

    Seems like your theme’s functions.php file is broken. Here is what you need to do. First connect to your website using an FTP client. Go to wp-content/themes/laboratory_child/ directory and then edit functions.php file. On line 20 you will see a closing curly bracket ‘ } ‘ This bracket is not supposed to be here.

    If this is a child theme, then you can backup your functions.php file and then delete it from your webserver. The parent theme’s functions.php file will take over.

  • Rachel

    Happened exactly to me last week. Thank you I will file this for the next time!
    Rachel