Hurry up, the offer is only valid until November 26, 2021! 30% OFF with the promo codeBLACKFRIDAY
Isn’t it frustrating to see a Parse error: Syntax error message? You feel like you did everything right, but the results were not what you expected.
Getting a syntax error on your WordPress site is nothing to worry about: it’s one of the most common error 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.
In this article, i’ll try to answer the most common asked questions about the Syntax Errors such as:
So let’s get started!
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 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.
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 clients 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 to 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. Starting monitoring WordPress PHP errors, is by the way an excellent way to do so!