Are you trying to fix syntax errors on WordPress?
The error can be caused by just one character, which makes it very common.
Getting a syntax error on your WordPress site is nothing to worry about: it’s one of the most common errors devs encounter when building something on WordPress.
You don’t have to be discouraged just yet. Continue reading to discover how to fix the WordPress syntax error.
Table of contents
Syntax errors occur when your code contains mistakes, so the compiler can’t parse the file and display your website.
The most common cause of syntax errors on WordPress is the wrong code in PHP scripts.
Among the mistakes to avoid are missing punctuations, incorrect variables, and incorrect function names, etc.
In WordPress, there are typically three distinct types of parse errors that may affect a site:
This is important to keep in mind that three different types of parsing errors refer to different scenarios, depending on the specific parsing error in the PHP code being written.
Fixing WordPress Syntax Errors
To begin, let’s identify where the problem lies.
If the error appears after you just installed new plugins or themes, it’s highly likely that those are what’s causing the issue. You can deactivate them to fix the issue.
If your WordPress admin dashboard is not accessible and so can’t do that – keep reading. It’s also possible to troubleshoot the WordPress syntax errors with the error message.
From the error message, you can also trace the problem since it contains the full path to the corrupted file. Furthermore, it gives the line number of the corrupted code.
In this example, you know that the corrupted file is functions.php and that the PHP error is located somewhere close to line 91. The syntax error is therefore in this file, so in order to fix this, you should modify this file with your FTP client.
Now that you’ve spotted the cause of the syntax error, it’s time to fix it:
From here, you can edit the file directly with your FTP clients or download the file, edit it with your HTML editor and upload it back.
To edit a file directly with Filezilla: click right on the file and then click on View/Edit.
FTP client editor mode might sometime be hard to read. I personally prefer to download the file and open it with my HTML editor so I can have a better understanding of the syntax.
Add whatever is missing or incorrect (in this example the ” after “Hello World!) – save your file and upload it up.
The parse error should be fixed!
The addition of code to your WordPress site is nothing to be ashamed about. Due to WordPress’ nature as an open-source platform, it is actually encouraged.
Yet you must be careful when making such changes because even the smallest error like forgetting the bracket can be very problematic.
Do not let this slip deter you from working on your site ever again.
This mistake should only be seen as a part of the learning process in web development.
In this article, I’ll show you how to easily turn off PHP errors in WordPress.
WordPress error logs started guide: All what you should know to set up and access WordPress error logs.
Everything you need to know about the PHP memory limit in WordPress and how to easily increase it to fix the allow memory size exhausted error.