WordPress is an open-source content management system (CMS) that anyone can customize to their needs. As a business owner, you’ve probably gotten curious about all these enhancements and personalization options, which then led you to YouTube videos and blog tutorials about how to do this and that. But, as you’re trying something new, you suddenly see a message saying: “Parse error: syntax error.” Uh-oh. Did you just break your website?
No need to panic yet! A syntax error is a minor issue in most cases, and it’s something many other users have encountered. If you’re reading this article, you’re probably looking for solutions to fix it. Well, you’ve come to the right place! We at Launch Digital know all about WordPress, and we’ve shared some simple ways you can fix this error on your website. Keep reading!
What Is “Syntax Error?”
In language, syntax is the set of rules that govern how phrases and sentences are formed. That doesn’t just apply to human language, but to computers as well. That’s their code. So, a syntax error on a WordPress website is simply code that’s not written correctly. It’s usually in the PHP, the scripting language used in web development.
As little as a missing symbol or a wrong function name will cause an issue. Because of this, the compiler cannot parse — process, read — the code. To put it simply, the compiler cannot understand what you’re commanding it to do.
This usually happens when you add snippets, install a new plugin or theme, or play with the code in general. Unfortunately, spotting the error just by looking at the code is like trying to find an incorrect preposition in a language you know nothing about. That’s why we’ve shared how to fix syntax errors in WordPress, so you can do it on your own.
How To Fix “Syntax Error?”
Okay. Let’s get to the part where we help you solve your problem. Just follow the steps below.
1. Finding the Corrupted Code or File
First things first, finding the culprit. You can’t fix the error if you don’t know what’s causing it in the first place. You’ll need to access the file with the corrupted code. In most cases, you’ll be locked out of your website. So, you’ll need a file transfer protocol (FTP) client to let you do that. Get one and connect it to your website so you can check the theme, plugin, or program file that’s wreaking havoc.
Now, you can start the search by debugging. This is where things get a little more technical, but just follow what we’ll say and you’re good. First, find the wp-config.php file and add this line to the code:
define( ‘WP_DEBUG’, true );
Add it on the line before “/* That’s all, stop editing! Happy blogging. */”. This will enable debugging. Save the file and open your website again. You should see an error message with a string of text. That will indicate the lines where the corrupted or incorrect code is located.
2. Fixing the Corrupted Code
Now that you know who’s behind this whole shenanigan, it’s time to correct the error of their ways so you can use your website once more.
A lot of “syntax error” cases occur because of faulty codes in plugins. Remember that WordPress is open-source, there are a lot of coding backgrounds and styles that may not be compatible with your own. Case in point: you just installed a new plugin or updated it, and suddenly you see the error. Now no one can enjoy the Custom Ratings plugin you want your customers to use on your products.
So, what can you do? Simply use the FTP client to access the wp-content/plugins directory. You’ll find the plugin file there. The first thing you can do is disable it. Go back to your website and see if that worked. If not, then you’ll need to fix the code yourself. To do this, install a code editor that will find the error for you. Then edit away!
Correcting code on a theme is almost the same as the process for a plugin, but it’s the wp-content/themes folder you’ll have to find this time. Then, find the functions.php file to access the code and edit away based on what the debugging message mentioned. If you can’t find it, then use a code editor. Once you’ve corrected the issue, go back to your website and verify it. Is it back to normal? Hooray!
3. Contact Your Hosting Provider
But what if it’s NOT back to normal? Don’t freak out! That’s nothing your hosting provider or IT expert can’t fix. Contact them if you’re not sure how to fix the error yourself or are too wary about editing codes. There’s no shame in admitting that you don’t know. In fact, we encourage you to let the professional do the work. It’s your safest bet!
What To Do To Prevent “Syntax Error”
No one wants to have “syntax error” appearing on their screens whenever they make a change on a WordPress website. To avoid this from happening, try the following tips!
- Learn PHP: Before you groan, we don’t mean learning it in-depth (though we’re not discouraging you to go down that road). Just understand the basics so you’ll know how to paste codes properly and use the correct symbols.
- Use a Code Editor: …so whenever you’re making changes to the code, you’ll spot the errors and correct them before publishing the changes. Handy!
- Enable Debugging Whenever You Edit Code: It works similarly to a code editor, allowing you to find errors before you save your edits.
Take Advantage of Launch Digital’s WordPress Care Plan
At Launch Digital, we’ll ensure that your website is running so you can continue running your business in South Africa. With our premier WordPress Care Plans, we handle many aspects of your website to help avoid issues like “syntax error” from occurring. We have many options depending on your needs, so come check out our packages today!