October 11, 2019
October 11, 2019
Isn’t it disheartening to see a Parse error: Syntax error message? You feel like you’ve done everything correctly, but the results are not as expected. Well, don’t be discouraged just yet. Read on to find out how to fix the syntax error on WordPress.
A syntax error occurs when there’s a mistake in your code. As a result, the compiler cannot process (parse) the file and fail to display your website.
On WordPress, syntax errors are usually caused by incorrect lines in PHP scripts. Some common mistakes are incorrect coding structure, missing punctuations, invalid variables, and wrong function names.
Here are the steps to fix syntax errors on WordPress:
Let’s begin by recognizing the source of the problem.
If the error appears after you’ve just installed new plugins or themes, there’s a high chance that they’re the ones causing the issue.
Alternatively, it’s also possible to trace the root of the problem from the error message because it contains the full path of the corrupted file. Furthermore, it mentions the line of the faulty code as well.
Let’s take a look at the following syntax error message:
We can see that the error is caused by the 72nd line of the index.php file. As such, this is the file you need to modify to fix the syntax error.
If your site shows a white blank page with no error message, enable the debug function or activate the display_errors feature by accessing hPanel -> PHP Configurations -> PHP Options. Then, you’ll see the message after you reload your site.
Now that you’ve spotted the cause of the syntax error, it’s time to fix it:
<?php get_footer() ;
In some cases, removing the line can also fix syntax errors. For instance, there is a comment that is missing escape characters and is thus being interpreted as code. Deleting this line will fix the error.
However, be careful if you want to delete a line as it may trigger another problem. A line that’s responsible for computing a variable’s value, for example, cannot be deleted because it is used later lines.
Encountering syntax errors may be frustrating as your WordPress site will not show its actual content.
However, fixing syntax errors is pretty easy. All you have to do is determine the corrupted file and modify it from the File Manager.
Follow our tutorial above, and your site will work properly in no time! Good luck!