How to Fix the Syntax Error in WordPress
This error usually occurs when you are trying to add code snippets into WordPress and have accidentally missed something or the code has incorrect syntax.
Example of parse error:
Parse error – syntax error, unexpected $end in /public_html/site1/wp-content/themes/my-theme/functions.php on line 278
The error message would indicate the unexpected thing found in the code and the location of the script where the error occurred with line number. To fix this issue you will have to correct the syntax.
Reason for why it’s happen
Most of the time it is a missing bracket or some unexpected character in the code.
Syntax Error Solutions:
Educate yourself on pasting code snippets into WordPress.
If you encountered this WordPress error after adding code snippets into your WordPress website, you need to learn more about pasting code snippets into WordPress or you will cause more damage.
Fix the affected code
If this WordPress error occurred after updating a plugin or pasting some code from the web, you know exactly where to look. The problem is you can’t fix your code via Appearance -> Editor (or Plugins -> Editor) since the syntax error locks you out of your website.But don’t be, you can easily edit your WordPress files via FTP or File Manager in your cPanel. Find the affected file and fix the code either by removing it or rewriting it correctly.
Try a different theme or plugin
If the error began when you activated a new theme or plugin then it’s most likely an error in that theme or plugin. So you might want to find an alternative one or contact the developer so they can fix the error. In some cases you might not be able to log into WordPress in which case you might have to delete the plugin or theme via FTP.