How to Overcome Syntax Errors in WordPress

Waryanto
Technical Content Writer, Loves the world of Technical IT, Digital Marketing & Travel Blogging. Likes to share new things that are useful for others.

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:

  1. Find the line of code that is causing the error
  2. 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.

style="font-weight: 400;">Then, you also need to recall the plugins or templates that have been installed on your WordPress site. If a syntax error appears after you install a plugin or template, it is likely that the syntax error was caused by the plugin or template. To fix this, please change the template or uninstall the related plugin.

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

error: Syntax error, followed by specific information about the error you’re experiencing.

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.

style="font-weight: 400;">This is how it looks.

syntax error

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.

Please

style="color: #3366ff;">login to the WordPress dashboardthen select menu Appearance > Editoror you can using FileZilla to edit the file.

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.

wordpress syntax error

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.

<?php get_footer()

syntax error in wordpress

style="font-weight: 400;">The code calls the function get_footer. If you pay close attention, there are parts that are incomplete, namely the absence of a semicolon at the end of the line.

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.

semicolon

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.

Conclusion

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!

Create by Ipadguides in category of Blog