Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Fix the Syntax Error in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
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.

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.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. fran garcia says:


    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?


    • WPBeginner Support says:

      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?

  2. Pradikta Rachmat says:

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

  3. Martin Watson says:

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

  4. Raj says:

    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

  5. Nick says:

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

  6. masterdungeon says:

    Error at last line of main.php.

  7. muhammad saeed says:

    Editor not found Please fix this

  8. inas dan says:

    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

  9. alex says:

    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!

  10. Kay says:

    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

  11. Sibel Baklacı says:

    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 and they don’t allow using ftp. What I can do to solve this problem. Please help!

  12. Mano says:

    Thanks a Lot, I did and got the problem solved

  13. zad says:

    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?

  14. Bharath Bhushan Naidu says:

    Any plugin to minimize css erros?

  15. Jaideep Bedi says:

    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!!!!

  16. thomas says:

    I’m creating a site using local host on my pc so its not gone live yet and i tried to change a bit of code in the editor in WP in the functions.php file. I got this error: Parse error: syntax error, unexpected ‘<' in C:\xampp 1\htdocs\wp\wp-content\themes\theme\keid-hosting\functions.php on line 43 and i now cant access my admin via the usual http://localhost/wp/wp-admin/.

    Ive tried to replace the functions.php file with an original from download and also i replaced all theme files with originals, still getting the error. I also tried to change the name of the theme and themes directory to try get it revert back to default theme (twentyfifteen etc…) but still getting the error

    Can you help me pls???

    Thanks in advance

  17. Erin says:

    Hello –

    I have a similar error. The site had a theme and I changed it. It worked fine and I was customizing when the issue happened. When I go into FTP the new theme files are not there- only the old theme is shown. How can that be?

    I tried to upload the new theme here to overwrite whatever is causing it to stay down but nothing is working. Any advice?


  18. Karen says:

    YOU are incredibly AWESOME! Your site will be carried around in my back pocket and shared with everyone I know that uses WP. Thank you for this valuable info. You saved my site!

  19. Andrew says:

    When I go to my website I get this error:

    Parse error: syntax error, unexpected ‘/’ in /home/cycletrk/public_html/wp-blog-header.php on line 12

    I know it’s a code error but I haven’t made any changes to the website for a while so the code just suddenly changed? I can log into the admin section site fine but I can’t find where this code is.

    Any help?

    • WPBeginner Support says:

      Try deactivating plugins. See how to deactivate all WordPress plugins when not able to access wp-admin. If this does not work, then try updating your WordPress site URL. Simply edit your wp-config.php file and add these two lines:


      Replace with your own domain name. It is possible that your site URLs are changed and have an unexpected ‘/’ at the end of the URL. IF this does not work out, then try deleting .htaccess file. If the .htaccess method solves the problem, then remember to visit Settings -> Permalinks page and click on update button to refresh your permalinks.

      • Matt says:

        Updated WordPress to 4.2.3 and the problem went away. Thanks a lot for your help. Much appreciated!

  20. Kristy Abbott says:

    Life saver! FTP did the job

  21. WPBeginner Staff says:

    See our FTP Tutorial

    Once you are connected through FTP locate the file where you pasted the code. Most probably you added it in /wp-content/themes/yourthemename/functions.php

    Download the file to your computer. Edit it to remove the code and then upload it back to the server.

  22. Lindsay Hoffman says:


    I’ve downloaded FTP but I have no idea what to do once inside besides logging in. How do I find my error and correct it?

    A little more background:

    I was trying to change where an ad on my page was by the code. Put the code in wrong so I can’t log into the page now. No idea how to change it back.


  23. Za says:

    If i am using mamp as my wordpress server, but now I am locked out because of the “Parse error: syntax error, unexpected”, does this mean I need to get a ftp account in order to edit my error?

  24. Eric says:

    Hi – I was able to login to my FTP by am unable to open the functions.php file. I keep getting a file transfer failed message. Any advice? Thanks!

  25. GM says:

    I’ve been trying to correct the syntax error I made whilst building my site, but the mapping for where I’m being told the error is doesn’t appear to exist when I try to access the site through FZ. I’m guessing it’s a similar issue to Jose’s last month. Any advice? Thanks

  26. K says:

    I cannot connect my site to FZ, it says ” Could not connect to server ” I already installed wordpress. And now I cant access my site because I accidentally pasted theme_hooks into theme_function. I don’t know how to find my server. Please HELP me, thanks

  27. Jose says:

    Hello, After editing the Functions.php I received a parse error on a certain line. Although I knew what the problem is the site is hosted on I can’t access the file via FTP. Any recommendations?

    Thank you in advance.

  28. K says:


    I got this error when I tried to access the my blog :(

    Parse error: syntax error, unexpected T_FUNCTION in /home/content/……../wp-content/plugins/easy-related-posts/easy_related_posts.php on line 75

    Please help. :(

  29. WPBeginner Staff says:

    Seems like your theme’s functions.php file is broken. Here is what you need to do. First connect to your website using an FTP client. Go to wp-content/themes/laboratory_child/ directory and then edit functions.php file. On line 20 you will see a closing curly bracket ‘ } ‘ This bracket is not supposed to be here.

    If this is a child theme, then you can backup your functions.php file and then delete it from your webserver. The parent theme’s functions.php file will take over.

  30. yamini priya says:

    Parse error: syntax error, unexpected ‘}’ in ………./wp-content/themes/laboratory_child/functions.php on line 20

    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…..

  31. Irfan Siddiqui says:

    Thanks a ton!

  32. diego says:

    Thank you for this post! It gave a big relief!

  33. Rachel says:

    Happened exactly to me last week. Thank you I will file this for the next time!

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.