• Categories
    • Tutorials
    • Beginners Guide
    • WordPress News
    • WordPress Security
    • Best WordPress Plugins
    • WordPress Themes
    • Product Reviews
    • WP Tips & Tricks
  • Guides
    • Start a Blog
    • Make a Website
    • WordPress Hosting
  • WordPress Hosting
    • A2 Hosting
    • HostGator
    • Bluehost
    • Cloudways
  • Managed Hosting
    • WPEngine
    • Rocket.net
    • WPX
    • Kinsta
  • Coupons
    • WPEngine
    • Flywheel
    • Cloudways
    • A2 Hosting
    • WPX Hosting
WordPress Tutorials

How to Fix the Parse Error Syntax Error in WordPress

Last Updated on: September 23, 2016 Lyn 5 Comments

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:

Parse Error Syntax Error

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

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)

Unexpected in Parse Error

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

Exact File in Parse Error

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

Exact Line in Parse Error

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.

FileZilla Settings

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

Exact File in Parse Error

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.

Root Directory public_html

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

  • Notepad++
  • Sublime Text
  • Atom
  • Brackets
  • TextWrangler

functions.php in Brackets Text Editor

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.

Correct PHP Syntax

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.

Upload Edited File to FTP Server

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

Refresh FileZilla Files

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.

Download WordPress

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.

+ Share
Disclosure

Lyn

Related Posts

Back to all articles
  • WP Activity Log Review

    WP Activity Log Review: How to Secure Your Site and Log Activity

  • How to Stress Test WordPress Using a Free Tool (Full Guide)

  • How to Increase the Memory Limit in WordPress

    How to Increase the Memory Limit in WordPress

Coupons

View more deals
  • LearnDash Coupon Code!
    40% off

    LearnDash Coupon

    Searching for a LearnDash coupon to save on one of the top W
    Get This Deal
  • WP Activity Log Coupon
    20% OFF

    WP Activity Log Coupon

    Website security encompasses a whole host of elements, tasks, and
    Get This Deal
  • Recipe Card Blocks Coupon
    15% OFF

    Recipe Card Blocks Coupon

    Running a cooking or food website can be fun (and tasty) – but
    Get This Deal
5 Comments Leave a Reply
  1. Paige says

    February 17, 2017 at 9:44 am

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

    Reply
  2. Divina Fallarcuna says

    March 9, 2017 at 2:51 pm

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

    Reply
  3. Raquel says

    August 8, 2017 at 7:01 am

    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!

    Reply
  4. Oli says

    November 2, 2017 at 11:10 am

    Thanks alot for this tips, the parse error is gone and my site is back up.
    I really do appreciate.

    Reply
  5. Sandy says

    February 7, 2018 at 8:23 pm

    Thank you so much, this step by step article saved my day!

    Reply

Leave a Reply Cancel reply

Full Disclosure This post may contain affiliate links, meaning that if you click on one of the links and purchase an item, we may receive a commission (at no additional cost to you). All opinions are our own and we do not accept payments for positive reviews.

Our Newsletter

Get awesome content delivered straight to your inbox.

Thank you!

You have successfully joined our subscriber list.

.

THE BEST OF WPKUBE

Some of the best content we have published so far.

BEGINNER GUIDES & REVIEWS

18 Best Cheap WordPress Hosting Providers in 2023 (From $1.99)
210 Best WordPress Hosting Options for 2023 (Pros & Cons)
38 Best Managed WordPress Hosting Providers for 2023 Compared
45 Best WooCommerce Hosting Providers Compared in 2023 (All Budgets)
5Top 9 Landing Page Plugins for WordPress (2023)
69 Best List Building Plugins for WordPress In 2023
7How to Fix the 500 Internal Server Error on Your WordPress Website
8Thrive Themes Review: A Look At The Full Membership
9Beaver Builder Review: Is it The Best Page Builder Plugin for WordPress (2023)?
10OptimizePress Review: Create Landing Pages with Ease
11How to Make a Website: Complete Beginner’s Guide
12Top 22 Best Free Stock Photo Resources For Your Site
1317 of the Best Google Fonts for 2023 (And How to Use Them in WordPress)
14How to Start a Blog in 2022 (Step by Step Guide)
15How To Fix ‘503 Service Unavailable’ WordPress Error
1611 Best Contact Form Plugins for WordPress in 2023
17How to Add a Custom Logo to Your WordPress Site
18How to Fix Error Establishing a Database Connection in WordPress

Cloudways: 30% OFF Deal

Save 30% on one of the best cloud hosting providers.

Get this Deal

Flywheel(our review)

Featured In Forbes Huffpost Entrepreneur SEJ

About WPKube

WPKube is an online WordPress resource which focuses on WordPress tutorials, How-to’s, guides, plugins, news, and more. We aim to provide the most comprehensive beginner’s guides to anything about WordPress — from installing plugins, themes, automated installs and setups, to creating and setting up pages for your website.

We have over 500+ tutorials, guides, product reviews, tips, and tricks about WordPress. Founded by Devesh Sharma, the main goal of this site is to provide useful information on anything and everything WordPress.

Twitter Facebook

Useful Links

  • Behind the Scenes
  • Beginner Guides
  • WordPress Hosting
  • WooCommerce Themes
  • MeridianThemes
  • Exclusive WordPress Deals
View All Guides »

Reviews

  • WPEngine 33% OFF
  • Thrive Leads
  • Flywheel 33% OFF
  • Divi Theme 20% OFF
  • Thrive Architect
  • Elegant Themes
Reviews »

Deals

  • InMotion Hosting
  • LifterLMS Coupon
  • LiquidWeb Coupon
  • WPEngine Coupon
  • A2 Hosting
  • FloThemes
More Deals »
© Copyright 2023 WPKube ® All Rights Reserved.
  • Contact
  • Site Terms
  • Disclosure
  • Privacy Policy