How To Solve Syntax Error In WordPress For functions.php?
August 20th, 2016 | by Ravi Chahar || 6 Comments |
There are many websites which provide the code to put in the functions.php file. But after adding the code, have you noticed the parse error on your website? When you add any new code in the WordPress file then most of the time, you don’t even look at the code, you just copy and paste it.
But when you notice the syntax error in WordPress and are not able to login to your WordPress admin panel then you freak out. For beginners, such type of error is really scary.
In this post, I am going to let you know how to fix parse error.
How To Remove Parse Error In WordPress?
The error may occur due to some simple and little things. When you add any extra element, character in the code then it will show the syntax error.
Even if you forget to add any parenthesis or the closing tag of the PHP then you will see this error. If you are a developer and have a little bit of knowledge about the PHP language then it would be so easy for you to find the error.
When it comes to the beginners then they should try to know about PHP codes and always check the code before adding in the functions.php file
Fix The Syntax Error In WordPress.
There are two possible ways to fix this error. You can use either cPanel and then edit the functions.php file or the FTP account.
1. From the cPanel
Just login to your cPanel and open the file manager. Find the functions.php file in the root directory and click on the edit option.
If you have moved WordPress from root directory to subfolder then you have to find this file in that subfolder and then edit this file.
When you receive the syntax error then you will see the path of the file in which error has occurred. There would be a line number given so that you check that particular line.
It’s not necessary that the error would be in the same line. You may skip any code snippet in the earlier lines which is connected to the last one. If you add anything extra in the code then maybe it will show an error.
2. From Using The FTP
You can access the WordPress files using the Filezilla with your FTP account. Just connect Filezilla and seek for the functions.php file in the WordPress directory.
The same procedure will be followed. There are many mistakes which can turn into the syntax error in WordPress. You have to check each and every line of the code nearby the mentioned error line.
You should try to keep your eyes on the code and find the extra added parenthesis, comma, or anything else which is not needed.
Did You Ever get Syntax Error After Adding A The Code In The functions.php?
It’s common when you run a WordPress blog and try to improve your WordPress theme or any other feature using the PHP code. Most of the time the code is used for the functions.php. But when you call any function in the single page, home page, or anywhere else then a little bit of code is added in other files.
It’s for the advanced level of the WordPress development. But if you copy any code from any website then try to check it.
How to remove parse error n WordPress? A question asked by many people. There is no specific way because of the possibility of the occurrence of the syntax error is high. You just keep an eye on the code you add and your won’t see any error.