How to Fix the Syntax Error in WordPress

Get real time updates directly on you device, subscribe now.

While editing WordPress themes or plugins, one small mistake can cause your website to stop working. That is why we always advise you to use a test or staging environment when adjusting your code.

Have you not done this or is something still going wrong when editing themes or plugins? Or did you install an update and something goes wrong? It may happen that you get to see a so-called “syntax error”.

What is a “Syntax error”?

A syntax error can be prevented by paying close attention when writing or adding codes to your theme or plugin. It often goes wrong when copying and pasting pieces of code that you have found online. To prevent this from happening I advise you to read the article  Beginner’s Guide to Pasting Snippets from the Web into WordPress from WPBeginner.com. A syntax error is usually caused by something very small, such as a missing comma or a sign too many.

The chances are that you know exactly what causes the syntax error on your WordPress website. Usually, the error occurs after adjusting files in themes or plugins. Have you recently added or modified a code? Then there is a good chance that something has gone wrong.

Where it goes wrong

Usually, a syntax error already indicates in which file and even on which line of code it goes wrong. An example of such an error:

Parse error: syntax error, unexpected ‘function’ …. in … \ private_html \ wp-content \ themes \ twenty seventeen \ functions.php on-line 235

This error indicates exactly in which file it goes wrong: in the functions.php file in the theme folder of “Twenty Seventeen”. The line of code where things go wrong is in this case “235”. Chances are that you (or your website developer) have recently changed something here.

WordPress “Syntax error”

Now that you have found out where the error is caused, you can solve the error.

1: Log in via FTP

Open your FTP client and log in to your server. Then go to the folder that indicates the syntax error and open the file (in the example above it is  \ private_html \ wp-content \ themes \ twenty seventeen \ functions.php ). Download this file to your computer.

2: Open the file

Now use a program such as TextWrangler  (Mac) or Notepad ++  (PC) to open the file. These programs indicate the line numbers so that you can easily find the rule that goes wrong.

3: Find the piece of code that causes the error and adjusts it

Now go to the line that shows the syntax error, and look at the PHP code on this line. Often it is simple things that do not go well, such as the lack of one; at the end of a line, using “curly” quotes ( see also ) or a “curly bracket” ( {or} ) that is missing.

Is there no error on the above line? Then look at the code around it, sometimes a piece of code on another line causes the error.

Does not it work? Then contact a WordPress specialist who can help you with this. Usually, they have solved it for you.

4: Upload the file via FTP and “refresh” your website

Now that you have changed the code, upload the file to the correct location via FTP. Now go back to your website and “refresh” ( Control + F5  on Windows or Command + R  on your Mac) the page. If all goes well, the error has now disappeared and your website is working properly again.

Conclusion

Usually, syntax errors are caused by very small errors in the PHP code on your WordPress website. A syntax error is therefore often fairly easy to solve. Does not it work? Please contact us.

Get real time updates directly on you device, subscribe now.

1 Comment
  1. idhoki says

    It’s remarkable designed for me to have a web page, which is useful in support of my knowledge.
    thanks admin idhoki.com

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More