WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Fix the Syntax Error in WordPress

How to Fix the Syntax Error in WordPress

Last updated on July 31st, 2017 by Editorial Staff
70 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Fix the Syntax Error in WordPress

There is such an abundance of WordPress tutorials, guides, and code snippets available on the web. They are all intended for users to try new things on their website and learn more about WordPress. Sadly a small little error can cause the whole site to break which is very scary specially for new users. If you were trying something new on your WordPress site and got a following error “Syntax error, unexpected…”, then don’t freak out. You are not the first one to receive the syntax error in WordPress, and you will not be the last one. In this article we will show you how to fix the unexpected syntax error in WordPress.

Using Proper Syntax to Avoid Errors

Syntax error in WordPress

First thing you need to do is to look at the beginner’s guide to pasting snippets from the web into WordPress. This article lists some very common mistakes made by beginners when pasting code in WordPress templates. The syntax error is usually caused by a tiny but crucial mistake in your code syntax. A missing comma, or an extra curly bracket can break the entire script.

Did you recently paste a snippet from the web? Updated a plugin? Then chances are you know exactly where to look.

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

Fixing the Syntax Error Using FTP

In order to fix the Syntax Error you need to edit the code that caused this error. You can either remove it or fix the syntax. Often beginners freak out because this error causes your entire site to become inaccessible. If you pasted the code using your WordPress dashboard Appearance » Editor section, then you are locked out. So how do you edit the code? Check out our guide on locked out of WordPress admin. The only way to fix this is to access the file you last edited using FTP (How to use FTP).

After installing the FTP program, connect it to your website and go to the theme file that needs editing. In case you forgot which file you need to edit, just look at the error code. The error will tell you exactly which file and which line you need to edit.

You can either remove the code you last added or write the code in correct syntax. Once you are done removing / editing the code, save the file and upload it back to your server. Come to your WordPress site and refresh the page, and your site will be working.

We hope this article helped you fix Syntax Error in WordPress. Please leave your questions and feedback in the comments.

70 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • How to Start Your Own Podcast (Step by Step)

    How to Start Your Own Podcast (Step by Step)

  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

85 Comments

Leave a Reply
  1. Roberta says:
    Jul 4, 2018 at 9:22 am

    This is a frustrating error and your tutorial allowed me to fix it in less than 5 minutes. Thank you so much!

    Reply
  2. Jamie den Haan says:
    May 24, 2018 at 7:37 am

    Hi,

    Can someone please help me out? I keep getting a ‘SyntaxError: JSON Parse error: Unexpected identifier ”Error” when i want to check out on my website. I don’t know what to do and nobody can place an order!!

    Thanks a lot,

    Jamie

    Reply
  3. Aaron says:
    May 16, 2018 at 12:05 am

    I get “critical error: could not connect to server” when I enter my server information. So I can’t even get to the point that your video begins at.

    Reply
    • WPBeginner Support says:
      May 17, 2018 at 4:46 am

      Hi Aaron,

      You can also connect to your server using File Manager app in your hosting account dashboard.

      Reply
  4. Daryl says:
    Oct 31, 2017 at 8:38 am

    You’re amazing. Thank you for these videos.

    Reply
  5. Raffy says:
    Oct 5, 2017 at 7:38 am

    Thank you SO SO much! The bad snippet was invisible inside the Admin page in WordPress, for some reason, but fully visible in the functions.php found in the FTP!!

    You saved my day, thank you very much again!

    Reply
  6. Kim martin says:
    Sep 10, 2017 at 9:44 pm

    Thank you SO much! 7 days of getting My hosting service(a very large popular one) to try to fix this no luck just trying to upsell me on things I neither want nor need.

    Me thinking okay a whole new website and i found this, I just actually deleted the whole plugin(elementor) Whoo Hoo!

    Reply
  7. Micah says:
    Sep 6, 2017 at 10:08 pm

    Hello:

    I have run into this error helping someone else out with their website, so I wasn’t using my actual website when I got this error. I’m wondering how I can remove the error when I’m working on someone else’s site? I have their wordpress. org login information, but obviously I’m locked out of everything now. Any guidance would be appreciated.

    Reply
  8. Tamia says:
    Sep 2, 2017 at 10:27 am

    Thanks for this tutorial. I had a parsing/syntax problem when editing functions.php in a new website. I was working on the admin page of my WordPress site when I attempted to comment-out a line of code (using instructions by the theme author) but that caused the error. I had copied the functions.php code to TextWrangler, made the alteration, and pasted the whole doc back into the edit window. In “updating” the page I got the error and was effectively locked out of the site. So I used FTP to upload and overwrite the relevant doc, using a backup I’d made the previous day (thank goodness for those). If it hadn’t been for WP Beginner’s clear instructions here and on the “What To Do When You Are Locked Out of WordPress Admin (wp-admin)” post, I’d have been tearing my hair out. Thanks!

    Reply
    • WPBeginner Support says:
      Sep 4, 2017 at 12:19 am

      Hi Tamia,

      We are glad you found WPBeginner article helpful :) Don’t forget to follow us on Facebook for more WordPress tips and tutorials.

      Reply
  9. stanley says:
    Aug 15, 2017 at 2:09 am

    Thanks for saving my website from errors

    Reply
  10. Tom Delano says:
    Aug 6, 2017 at 11:05 am

    In trying to log into my page via Filezilla, am I supposed to use my admin account or my WordPress account? I’ve tried both and the password authentication keeps failing. I have my original admin password and it’s worked consistently since I’ve had the website up.

    Reply
    • WPBeginner Support says:
      Aug 7, 2017 at 9:42 pm

      Hey Tom,

      You’ll need to use your FTP username and password. You will find it in the email you received from your web hosting company when you first signed up. You can also find this information under your cPanel dashboard.

      Reply
  11. chris says:
    Aug 2, 2017 at 1:41 pm

    thank you so much! you saved me

    Reply
  12. Justine says:
    Jul 31, 2017 at 8:13 am

    I urgently need help. CO-editor on my site (which is supposed to launch tomorrow) tried to change code to change our profile pictures. Something went horribly wrong and we locked out of our site. Get this error: Parse error: syntax error, unexpected ‘add_filter’ (T_STRING) in

    Reply
  13. Giacomo Lawrance says:
    Jul 5, 2017 at 12:07 pm

    Thank you so much! You really saved me there. So grateful of this awesome site, thanks again!

    Reply
  14. Sara says:
    Jun 25, 2017 at 5:28 pm

    You saved my life!
    Thank you so much! :)

    Reply
  15. Monica says:
    May 11, 2017 at 12:10 am

    Re: my last comment, I deactivated the plugin and the error went away. So you won’t see what I was describing anymore. I just decided to not use it than try to spend all night figuring out the problem.

    Reply
  16. Monica says:
    May 11, 2017 at 12:05 am

    I am getting parse error syntax errors on all my product pages. This was brought to my attention by someone trying to shop my site. I have not made any edits to the code, installed any new plugins, or accessed the site at all in months. Not sure when this started but I haven’t had an order in few weeks. If I didn’t add or edit anything to cause this how do I know what to fix? All the error messages reference line 1 of the php file but all there is on line 1 is <?php. It's on all product pages. Here is just one example:

    Reply
  17. shazwan says:
    Apr 15, 2017 at 9:26 pm

    Hi,

    I’m managing a website for my society and its has been long since the last time everyone actually had logged into the hosting account and we kind of lost the log in credentials and didn’t even know what hosting we’re using because they paid years ahead before. And maybe changed providers. But I know that our domain is from Godaddy and checked, but the hosting isn’t from the same provider.

    It may take some time as we dig through the emails, is there any way to fix syntax error other than through FTP?

    Reply
    • WPBeginner Support says:
      Apr 16, 2017 at 8:03 pm

      Hi shazwan,

      Unfortunately there is no way around it. There are online tools that will help you figure out where you website is hosted.

      Reply
  18. Patrick says:
    Apr 8, 2017 at 3:46 am

    Hi. I tried uploading a theme though Filezila since WordPress was having issues trying to upload the theme and now I’m locked up and I get these two lines

    Please Help!!! Thank you!

    Reply
    • WPBeginner Support says:
      Apr 10, 2017 at 12:25 am

      Hi Patrick,

      Seems like upload was interrupted. Please try uploading the theme files again.

      Reply
  19. Mark Perkins says:
    Apr 6, 2017 at 6:44 pm

    Awesome this is the best site on wp. saved ne again.

    Thank you so much

    Reply
  20. Francisco says:
    Mar 31, 2017 at 12:56 pm

    Hello,

    I got this error after I updated some plug ins,
    Parse error: syntax error, unexpected ‘var’ (T_VAR) in /home/smilesonbristol/public_html/wp-content/plugins/jetpack/sal/class.json-api-date.php on line 55

    Please help.

    Reply
    • WPBeginner Support says:
      Apr 2, 2017 at 6:38 pm

      Hey Francisco,

      First you need to deactivate all WordPress plugins. After that activate them one by one until you get the error again. This will help you find out exactly which plugin is causing the error. You can then contact the plugin support.

      Reply
  21. Spring says:
    Mar 22, 2017 at 3:57 am

    I cannot thank you enough! You have saved my life! I was to a break point as I thought I’d lost my entire 2 days of work on my new website. Now I have ftp’d the file, and I am back in wp-admin again! Thank you so much for your wonderful site.

    Reply
    • WPBeginner Support says:
      Mar 22, 2017 at 11:13 pm

      Glad you found it helpful :) Don’t forget to follow us on Facebook for more WordPress tips and tutorials.

      Reply
  22. sangeet kumar says:
    Mar 18, 2017 at 2:37 pm

    hi

    Parse error: syntax error, unexpected ‘define’ (T_STRING) in /home/designba/public_html/wp-content/themes/hestia/functions.php on line 1

    i got the above error message. i cant access any page. i did every steps you mentioned, but i am getting same problem again. actually i didnot change anything in functions.php

    Please Help

    Reply
  23. Ashley says:
    Mar 2, 2017 at 5:11 pm

    Parse Error: syntax error, unexpected T_FUNCTION in the theme section. I try to fix the error in FileZilla but I’m getting “Critical error: Could not connect to server”. PLEASE HELP

    Reply
    • WPBeginner Support says:
      Mar 3, 2017 at 5:10 pm

      Please check your FTP username, password, and host information. You may have received this information in an email when you signed up for your hosting account. You can also ask your hosting support to provide these details.

      Reply
  24. Jim says:
    Feb 10, 2017 at 10:02 am

    You guys are awesome.. Saved my life..

    Reply
  25. daphne says:
    Feb 2, 2017 at 6:55 am

    Here’s another one:
    logged on to the FTP (as suggested by this blog…thanks for that!!), found the files…. but couldn’t download them:
    ….Status: Starting download of /www/wp-admin/theme-editor.php
    Error: Failed to open “/theme-editor.php” for writing
    Error: File transfer failed…..

    idea? Anyone?

    Reply
    • Raffy says:
      Oct 5, 2017 at 7:44 am

      I had the same problem, a red error message when I tried to download it from the right-click window: so I simply searched for my desktop, dragged the file there, edited it, deleted the old functions.php file in my wordpress and dragged the new edited file in the same place. Hope this helps.

      Reply
  26. Deb says:
    Jan 29, 2017 at 12:55 am

    I cannot tell you how much you’ve saved my life!!! Well, my blog!!! Follow every step, guys!

    Reply
  27. Kathleen says:
    Jan 21, 2017 at 12:57 am

    I am getting this error. I did what you said, pasted in some code that didn’t work. When I took the pasted code out, it still gave me the error. So, fine, I just copied the whole file from a fresh download, and I’m still getting the same error, so I have no idea of what to do now.

    Reply
  28. Stephen says:
    Jan 17, 2017 at 12:07 pm

    This article saved my life – lol. Thank you so much for the step by step. Fortunately, I had copied and pasted the good code into a text file so going back was easy after I understood what I was looking for.

    Reply
  29. Tracie says:
    Dec 30, 2016 at 11:41 pm

    OMGosh, thank you for this post! That just happened to me, and I thought I had lost my site for good. What a relief to know the solution was as simple as using FTP.

    Reply
  30. Walter says:
    Dec 2, 2016 at 12:53 pm

    Hi guys,
    I need some help to solve this issue below quickly please

    ——————————————————-
    Parse error: syntax error, unexpected T_FUNCTION in /home/cardapio/public_html/wp-content/themes/zerif-lite/inc/customizer.php on line 41
    ——————————————————-

    I saw a comment below talking about a video explaining an solution but i didn´t find the link… somebody could help me please?

    Reply
    • Walter says:
      Dec 2, 2016 at 12:59 pm

      This error happen after I made the plugin´s update by WP Painel.. and now I can´t access the WP Painel anymore… only by FTP

      Reply
  31. Mikael Andersen says:
    Nov 24, 2016 at 9:53 am

    Would it be possible for the WP developer team to develop some kind of a script, that is checking out the code syntax in the functions.php file in order to prevent the user from saving the file if it contents any error.

    I think it could be of a big help for many users, especially if a user has taken a copy of the file before making any changes in it.

    Reply
  32. Imran says:
    Nov 15, 2016 at 4:25 am

    Hello guys ,

    Can anyone help me with this, I’m having an error when i check my blog health on I dont know how to fix this error. I have tried so hard but couldn’t fix it.

    Improper use of href attribute

    The href attribute specifies the URL of the page the link goes to. Without this attribute, the <a> is not a hyperlink.

    How to solve this issue

    This is essentially a broken link and therefore should be fixed asap so as to not affect SEO negatively.

    Thank you

    Reply
    • WPBeginner Support says:
      Nov 16, 2016 at 11:01 am

      Hi Imran,

      You will need to edit the post or page and locate the broken link and then delete it.

      Reply
  33. Samuel Muiruri says:
    Nov 15, 2016 at 12:57 am

    I’ve got an error Parse error: syntax error, unexpected ‘;’ in /home/runningw/public_html/test/wp-content/themes/travel-lite/inc/customize.php on line 167 I was editing customize_register for a theme and on upload on complete it crashed.

    Reply
  34. Rachel says:
    Nov 14, 2016 at 10:17 am

    Thank you. This video saved me! Clear information for someone who would not even call themselves a beginner yet! Very much appreciated!

    Reply
    • Walter says:
      Dec 2, 2016 at 12:46 pm

      Where is this video´s link?

      Reply
  35. Kristian says:
    Nov 13, 2016 at 4:12 pm

    Thank you!!!

    Reply
  36. fran garcia says:
    Oct 16, 2016 at 1:05 pm

    Hi.

    I got the same problem, but searching for the theme folder, THERE IS NO FOLDER named like that, so I can’t edit the php!

    Any ideas about how to proceed?

    Thanks.

    Reply
    • WPBeginner Support says:
      Oct 16, 2016 at 3:44 pm

      Can you find the wp-content folder or can you see any WordPress files when you connect to your site using FTP or File manager?

      Reply
  37. Pradikta Rachmat says:
    Jun 23, 2016 at 12:01 am

    Thank you very much, I can access my blog now.

    Reply
  38. Martin Watson says:
    May 26, 2016 at 4:17 am

    This post is awesome! Worked for me in 30 mins!

    Reply
  39. Raj says:
    Apr 19, 2016 at 4:51 am

    Parse error: syntax error, unexpected ‘:’ in /home/rev/public_html/wp-content/plugins/facebook-pagelike-widget/short_code.php on line 28
    i got above error message cant access my website please help me

    Reply
  40. Nick says:
    Apr 7, 2016 at 5:31 am

    It really was a moment to freak out, but thanks to your article it was fixed in a matter of time. Thanks a lot!!

    Reply
  41. masterdungeon says:
    Mar 29, 2016 at 8:35 am

    Error at last line of main.php.

    Reply
  42. muhammad saeed says:
    Feb 27, 2016 at 1:27 am

    Editor not found Please fix this

    Reply
  43. inas dan says:
    Feb 16, 2016 at 3:21 am

    i have this error in function.php in twenty sixteen chiled theme

    Parse error: syntax error, unexpected ‘<' in /home2/hmh49/public_html/myplog/wp-content/themes/twentysixteen-child/functions.php on line 10

    please help

    Reply
  44. alex says:
    Feb 11, 2016 at 4:12 pm

    It worked beautifully! Thank you!
    I was on a verge of having a shock seeing that my page was not available anymore but thanks to your help I managed to fix the issue! Thank you million!

    Reply
  45. Kay says:
    Feb 2, 2016 at 12:30 pm

    Hi there,

    I am needing help to fix this error please
    Parse error: syntax error, unexpected ‘}’ in /usr/www/users/ogbuldwqdf/wp-content/themes/theme53993/includes/sidebar-init.php on line 51

    I pasted the same code back, but still getting the problem

    Reply
  46. Sibel Baklacı says:
    Jan 22, 2016 at 5:06 pm

    I have changed my theme’s functions.php file a little bit and now I have an syntax error. Functiıns.php parse error. I can’t access my site anyway. I can’t use ftp to access to it because my site hosted on wordpress.com and they don’t allow using ftp. What I can do to solve this problem. Please help!

    Reply
  47. Mano says:
    Dec 15, 2015 at 6:17 am

    Thanks a Lot, I did and got the problem solved

    Reply
  48. zad says:
    Nov 25, 2015 at 2:03 pm

    hi
    i have big problem, help me please :(

    Parse error: syntax error, unexpected ‘$content_width’ (T_VARIABLE) in /home/u369283888/public_html/wp-content/themes/mharty/functions.php on line 1

    i used FTP what kan i do to fix it?

    Reply
    • Ark says:
      Nov 26, 2015 at 8:41 am

      I think you miss , after php statement.please check it carefully.It is not a big issue.

      Reply
      • ZAD says:
        Nov 27, 2015 at 5:21 am

        I will check..

        Thanks..

        Reply
  49. Bharath Bhushan Naidu says:
    Nov 25, 2015 at 7:24 am

    Any plugin to minimize css erros?

    Reply
  50. Jaideep Bedi says:
    Sep 24, 2015 at 1:39 pm

    I’m stuck in the white screen of death…i did not pasted a code but did a very tiny editing(Appearance->editor) ….it worked and i got what i wanted but later when i tried loading page, it never loaded. On inspecting Element it says: Syntax error Unexpected ” } ” .
    I undo that tiny editing but nothing happend….. please help!!!!
    URGENT

    Reply
« 1 2

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
All in One SEO logo
All in One SEO
Improve website SEO rankings with AIOSEO plugin. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
SeedProd Logo
SeedProd Coupon
Get 50% OFF SeedProd Coming Soon Page plugin for WordPress.
Cozmoslabs
Cozmoslabs Coupon
Get 15% OFF on Cozmoslabs WordPress premium plugins.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.