How To Solve Syntax Error In WordPress For functions.php?

syntax error in wordpress

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.

fix parse 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.

how to remove parse error in wordpress

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.

by Ravi Chahar

A blogger, web developer, and designer who intend to guide his readers about WordPress, Blogging, Web Development, Web Design and more. I have expertise in WordPress theme development and customization. I can set up and redesign the Thesis themes. I have been working in this field for years now.

6 comments

  1. Just like you said, I also freaked out when I got this error for the first time.
    The worse thing was I wasn’t able to fix it immediately and my blog remained carrying that error for 2 days. Later I found the guide online and fixed it. I was very happy.
    I can now relate it your post. I have followed the second method you have mentioned. But I have used different FTP. You may also mention other such tools. Thanks

    1. Hey Sherab,

      Most of the time when you enter any code in the PHP files, you should check each and every line. The syntax error isn’t a kind of error which is hard to fix. You just have to keep your eyes on the code.

      Check the code around the line mentioned in the error. Most of the time if you add anything unexpected then parse error appears.
      It’s your personal choice, you can use any FTP tool.
      Thanks for stopping by.
      Enjoy the day.
      ~Ravi

  2. Hey Ravi,

    Glad to read your wonderful post,

    Syntax error are commonly seen in WordPress, sometimes we suffers a lot from this problem. You have explore great way to fix the syntax error by cPanel and FTP.

    These method are looking very simple to learn and it may very beneficial for us. Really these are best information to execute such problems.

    Eventually, thanks for sharing your worthy post.

    With best regards,

    Amar kumar

    1. Hey Amar,

      When you try to edit the PHP code of the WordPress files then sometimes an extra code can cause the syntax error. The FTP method is quite good only if you can’t able to access the cPanel.
      But if you can access it then go for the cPanel and edit the file consists the error. I am glad that yu found it helpful.
      Thanks for taking time to share your words.
      Have a great day.
      ~Ravi

  3. Hi Ravi. I get syntax errors all the time because I like to write and modify my own plugins. It isn’t a big deal for me as long as it is my own code that caused the problem. Once or twice I have received the error after updating a plugin and I don’t enjoy going through someone else’s code to find errors.

    I know WordPress lets people modify live code, like their active theme or any of the active plugins. It’s usually a bad idea. Instead, deactivate the theme or plugin first, then add the code. When you attempt to reactivate the theme or plugin WordPress will usually detect the error and prevent the activation. You still have to fix the problem, but your website will still be available for your visitors in the meantime.
    Ben recently posted…Do You Have to be an Expert in Network Marketing?My Profile

    1. Hey Ben,

      It happens with most of the developers and it’s easy to find the error in your own code. Every developer has his/her own style of coding and I would take the time when you try to find the errors in the WordPress themes and plugins.

      It’s a good idea that the bloggers should deactivate the theme or the plugin and then try to find the errors.
      Thanks for taking the time to share your amazing thoughts.
      Have a great day.
      ~Ravi

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge