July 4, 2017
2 min read
New WordPress users often encounter difficulties when their managed website displays posts Parse error: Syntax error, unexpected. Through this tutorial we will discuss how to fix this. We present the steps here in a simple way to make it easier for beginners to understand.
What do you need?
Here’s what you need to get started with this tutorial.
Fix Syntax Error in WordPress
You can easily fix syntax errors on your WordPress website or blog in just two steps:
- Find the line of code that is causing the error
- Modify the code by connecting to the server
Step 1: Find the Cause of the Syntax Error
The first step to fix syntax errors is to find the source of the main problem. Here you need to find the file that caused the error, or specifically, which line of code it is in.
If the above is not the cause of the syntax error, you can still track it down easily. See the message that appears when you access the website. Usually, the message starts with Parse
The error message also displays complete directory information of the file along with the line of code that caused the error. The files mentioned there are what you need to fix so that your WordPress website can run properly again.
Here you can clearly see the file and line of code that caused the error: file single.php on line 43. This information clearly shows the root cause of the problem before you start fixing WordPress syntax errors.
Step 2: Repair Files Using FTP Client
In this step you have found the file causing the error. Next, you can edit the code in the file in question so that your WordPress website can work again.
After you have successfully connected to your hosting account via FileZilla, please access the file that caused the error. According to the message listed, the file is in the directory /home/u694443746/public_html/wp2/wp-content/themes/twentyseventeen/single.php. Find the file, then right click and select View/Edit.
The file will open in the default text editor on your computer.
Optionally, here you can remove the code that caused the error or modify it so that the website can run normally again. Modification methods usually only work according to the cause of the error and may differ from case to case. Therefore, you need to do further checking.
In this example, the error is on line 43. Here is the line of code.
Here the cause of the error can be fixed easily. You just need to add a semicolon at the end of the line of code and upload it back to the server.
If you are still a beginner in PHP, you can use PHP code checker to check the code and see the error most often cause errors in PHP.
If you are still a beginner, you don’t need to worry if you can’t find a syntax error on the WordPress website that you manage. The syntax error message is not a problem you need to worry too much about. This is one of those problems that is easy to identify and you can fix yourself.
Want to keep getting interesting articles from Niagahoster Blog directly from your email? Click Subscribe now!