Tips

How to solve a syntax error in WordPress?

If you have seen the “Syntax Error” message in your WordPress, do not be alarmed! Here we explain ways and tools to solve it.

What’s a syntax error?

Often this error happens because a programming language is not used properly, that is, the rules are not followed and the code is written incorrectly. It can be something as simple as not placing a semicolon, or that a complete file is misspelled. When compiling, it will not be understood and that error will appear. The positive thing about this error is that you will know exactly what it is about and we will see how to correct it.

How to detect where the syntax error is?

  • If the error appeared just after you have pasted some block of code, check the latter mainly.
  • Anyway, in the syntax error message you will see the damaged file and the line of code that you should review. This is also seen when you activate the debug by defining define (‘WP_DEBUG’, true); in wp-config.php.
  • Check that you do not miss any semicolons. There are codes that at first glance do not seem to have an error, and when adding a semicolon at the end the message disappears.
  • Check that the quotes are in the proper format. That is, in PHP the double and single quotes are used, make sure they are not italic.
  • Check that there is no missing parenthesis to open or close.

Tools that can also help you

PHPStorm

It is an IDE considered quite complete, with its paid version of monthly or annual membership (USD $ 199) you can receive all the updates. PhpStorm is part of JetBrains, and they offer the whole package (including PHPStorm) for USD 649 per year. However, they offer a version for university students, with the prohibition of use for commercial purposes.

Visual Studio Code

It is a code editor with many features for beginners and experts. Visual Studio Code also accepts multiple extensions and customizations.

What if none of the above works?

Check if the error started when you activated a new theme or plugin. It may be a mistake of them, so you could replace it or contact the developer. Often this error does not allow you to login to WordPress, so you must use FTP to remove the plugin or theme.

Did this post help you? Tell us!

Jefferson Maldonado
the authorJefferson Maldonado
UX WordPress Designer
Ux & Web Designer. Portafolio: http://maldonadoz.com/portafolio/ Divi Blogger, WordPress Expert, UX Designer, Business Consultant.

Leave a Reply

× Hey there !