WordPress Tutorials

How to Fix the Parse Error Syntax Error in WordPress

The parse error syntax error in WordPress isn’t a common error, and it typically occurs through a mistake made by the user. Experienced developers often have no trouble fixing this error on their own, but if you’re new to adding and editing code to your site, you may be having a tough time figuring this error out.

You might be stuck on how to even attempt to fix the error as the parse error may have locked out of the admin area of your site. We’ll show you how to access your site’s files through an FTP server so you can fix this issue without needing to log in through wp-admin.

Let’s get started.

What Causes the Parse Error Syntax Error in WordPress?

The parse error syntax error looks like this when it appears on your site:

The cause of your error will be different than the one depicted above, but each error shares similar parts when broken down:

Parse error: syntax error

This tells you there’s a syntax error on your site. Syntax is “the arrangement of words and phrases to create well-formed sentences in a language.” In programming, this means things need to occur in a certain order.

When a parse error or syntax error occurs, it means something didn’t occur in the order it was supposed to, and that’s where we get into the second part of this error.

Unexpected (fill in the blank)

The second part of the parse error will say things like “unexpected $end,” “unexpected ‘.’,” etc. This tells you exactly what the problem is. Unexpected $end means you didn’t close something properly. Maybe you forget to add a parenthesis or forgot to close a bracket.

If you get something along the lines of “unexpected ‘.’,” this means you added something you shouldn’t have, a period in this case.

Exact File

The next part of the error tells you exactly where the problem is located. If you’ve never accessed your site’s files outside of the Editor in the WordPress admin area, you may find yourself getting lost at this point.

Just make sure you make note of this part as it’s telling you the exact file path of where the problem is located.

Exact Line

It’s difficult to see when you only edit files in the WordPress Editor or general text editors, but all of the lines in your files are numbered. That’s what the end of this error is about. It tells you the exact line the error is occurring on, which saves you from having to go through every little bit of code yourself.

Accessing Your Site’s Files via FTP

When you can’t edit your files through the WordPress Editor, your best bet is to use an FTP client. An FTP client gives you access to your site’s files through an FTP server. It’s similar to how you access your site’s files through your host in cPanel.

There are a number of different FTP clients to choose from, but I’m going to show you how to set up FileZilla for the purpose of this tutorial. Click here to download FileZilla. Make sure you choose a version that’s compatible with your operating system.

Install the program on your system, and open it. Click File, and select Site Manager. Enter your site’s name to label your site, and enter the following settings:

  • Host – Your domain example.com
  • Port – Leave blank.
  • Protocol – FTP – File Transfer Protocol
  • Encryption – Only use plain FTP (insecure)
  • Logon Type – Normal

Use the username and password you use to access your site through your host as your username and password in FileZilla. For instance, if your host uses cPanel, use the username and password you use to sign into cPanel.

Open the Transfer Settings tab. Check Limit Number of Simultaneous Connections, and enter 8 as the Maximum Number of Connections. Click Connect to connect to your site’s files through the FTP server.

Fixing the Parse Error Syntax Error Through the FTP Client

I’m going to reference the error in the image above as an example. The last part of the file path tells you which file contains the error. This is functions.php in the example I gave above.

The rest of the file path tells you exactly where the file is located. If you go backward in the example above, you can see the functions.php file is located in the Zerif Lite theme’s folder, which is located in the main Themes folder, which is located in the wp-content folder, which is located in my site’s root directory.

The root directory is public_html for most sites, so open that first in FileZilla. Use your own error to locate the file that contains the parse error.

Double-click the file once you find it to download it to your computer.

Finding the Parse Error

The easiest way to open a PHP file is to open it using the default text editor on your computer. If you’re having trouble finding the exact line the error is referring to, download a text editor meant for programmers and open the file in that.

Popular text editors include

These programs number each line of your file, as you can see in the image above, making it simple for you to find the line that contains the error. Fixing it is either hard or easy depending on your level of experience with code and how the error got there in the first place.

Fixing the Parse Error Syntax Error

The world of WordPress is filled with tips and advice containing “paste this code here” and “paste this code there.” This is great, and it’s a wonderful demonstration of how wide and helpful the WordPress community is, but mistakes happen.

Plus, if you’re new to adding and editing code, you’ll likely make mistakes, and it’s okay. However, it’s important for you to learn exactly which mistakes you make so you can correct them and prevent them in the future. Let’s go over a few different reasons why this parse error might be displaying on your site.

See if the error is simple to start off with. See if you forgot to add a semicolon or a closing bracket. Little errors like these are easy to overlook, especially if you’re adding your own code.

If you pasted code into your file, make sure you pasted it correctly. Every PHP file starts with an opening <?php tag and ends with a closing ?> tag. Everything must fall between these two tags.

Some tutorials tell you to paste code at the bottom of your files, which can be confusing for beginners, causing them to mistakenly paste the code after the closing ?> tag. If you pasted your code after the closing tag, simply copy it again, and paste it before the closing tag.

If you added the code yourself and cannot figure out how to correct it, simply remove it from the file.

Uploading the File Back to Your Site

Once you’ve found and corrected the error, save the file in the text editor you’re using. Open FileZilla, and make sure the folder that contains the file is still open.

There are four panels in FileZilla. Focus on the bottom two. The folder you have open should be on the right side. Use the bottom left panel to navigate to the folder on your computer where the edited file is located.

Drag the edited file from the left panel over to the right panel, and overwrite the original file when prompted.

Refresh the FTP client by clicking the button at the top, as seen in the image above. Refresh your site to see if the parse error goes away.

Fixing the Parse Error by Uploading Fresh Versions of Files

If you cannot figure out how to fix your code, try uploading a fresh version of the file. If your theme is the problem, download a copy of it (the version you’re using). If you only have the original folder archived and have only updated the theme through the WordPress admin ever since, download a fresh copy of it from your theme provider.

If your problem is with WordPress in general, download a fresh copy of WordPress from WordPress.org.

Whether you download a copy of your theme or a copy of WordPress, make sure the version you download is the same version you’re using. If you update everything as soon as it’s available, you shouldn’t have an issue.

You can download older versions of WordPress by clicking the Release Archive link in the menu on the left-hand side of the download page.

If you do choose the WordPress root and your problem is with wp-includes or wp-admin, you can safely upload fresh copies of these files to your site. Never upload a fresh copy of wp-content as this will delete content from your site.

Use the same steps explained in the Uploading the File Back to Your Site section of this post to upload a fresh copy of the file to your site.

Final Thoughts

There is nothing wrong with editing or adding your own code to your WordPress site. In fact, it’s encouraged due to WordPress’ open-source nature. However, it’s important to be careful when doing so as the smallest mistakes, such as forgetting to add brackets, can cause major issues.

This mistake shouldn’t keep you from adding your own code to your site ever again. Web development and web design have huge learning curves, and you should only treat this mistake as a part of the learning process.

With that said, check out Daryn Collier’s post featuring 16 useful code snippets for WordPress.

Lyn

View Comments

  • This article SAVED me! Step by step this was the perfect guideline. I carefully hung on to each step to get through this. Very well written. THANK YOU!!!!

  • I was able to connect ftp on filezilla but i cannot find the public html folder. Please help!

  • Wow, I can't thank you enough. I never would have trusted myself to fix that kind of problem on my own, but with your clear instructions I managed to fix it! Thank you!

Recent Posts

SeedProd Review: A ‘New-Old’ Plugin to Help You Build Full WordPress Websites

SeedProd is one of the elders of the WordPress ecosystem. It's also a bit of…

1 week ago

Dealing with WordPress RSS Feed Errors: How to Identify and Fix Them

Really Simple Syndication (RSS) feeds are a vital component of the WordPress ecosystem. They act…

3 weeks ago

Top Black Friday and Cyber Monday Deals for 2024

It’s that time of year again when people start revving up their shopping lists, hunting…

4 weeks ago

6 Superb WordPress Recipe Plugins Compared for 2025

Forget music being the food of love, WordPress has a love for food. You can…

2 months ago

6 Best WordPress Translation Plugins for a Multilingual Site (2025)

If you clicked on this post, I’m guessing you want to find the best solution…

2 months ago

How to Start an Online Course Using WordPress and LearnDash

Trying to figure out how to start an online course so that you can share…

2 months ago