We received this very long WordPress error when trying to manually edit and save the header.php file in our current WordPress theme (we’re using Awaken by ThemezHut). The very verbose error below manifested after clicking Update File to save our changes to header.php:
Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.
This is one of those classic vague WordPress errors that doesn’t give you much information beyond the fact that your change cannot be saved. Now, your scenario may be different, but we found a way to troubleshoot the issue and pinpoint where this was breaking.
Background
The reason that we were editing the header.php file in the first place was to insert the Adsense code before the closing head tag as per the standard Adsense Auto ads setup/configuration. Trying to save the changes in header.php after clicking on the Update File button resulted in the above very vague error.
What is causing this WordPress error to appear?
The verdict is still out on this but the assumption is that something in my current WordPress theme changed during the last update. What that change was exactly is anyone’s guess and while it would be helpful to determine what that was, figuring out the issue with updating header.php is the important thing.
The Solution: How to resolve the issue with being unable to save changes to header.php
The easiest way to get around this issue is to manually edit your header.php, add the Adsense code to it (or any other changes), and upload the file to your website using cpanel or FTP.
Additional Troubleshooting
Prior to uploading the file to cpanel, I did a lot of troubleshooting on this issue as I wanted to see where the error lay in the first place. So after trying to add the AdSense code and failing after many attempts I went through these steps to determine where the error lay. Let’s review these steps:
1. From inside the Theme Editor, click Update file without making any modifications. We tried this and still got the above error. With this we can deduce that the issue is with the header.php code and not with the Adsense code.
2. My guess here was that the Theme Editor doesn’t like something in the header.php code. In order to determine where the issue was, I decided to try to wipe the header.php file and see if we could save the file. If so, I would re-introduce the code line by line. WARNING (If you’re not comfortable clearing the contents of header.php, don’t proceed)
3. WARNING #2 Clearing the header.php file and clicking ‘save’ is going to break your website temporarily, until we fix it. Again, if you’re not comfortable with that, don’t proceed.
Before clearing your header.php, make sure that you have a backup. Note that you can always restore the original header.php from your current theme package.
So I cleared the header.php file and clicked on ‘save’. This time, we could save successfully, although now running with a blank header.php file, our site does not look very good. However, this supports our theory that something is indeed wrong with the original header.php code.
4. From the backup header.php file, I copied the first few lines back into header.php in the Theme Editor and click ‘save’. This was successful as well which strengthened the theory that the issue had something to do with the current header.php code.
5. After reintroducing most of the code, I found that the following section relating to the Search Form was causing the Theme Editor to throw that error. When I omitted this line of code, I could save the file. However, we still want this code which is why I ended up just uploading header.php directly to the server via cpanel, which is kind of a pain!
<form action=”<?php echo esc_url( home_url( ‘/’ ) ); ?>” id=”awaken-search-form” method=”get”>
Anyhow, long story short, this is how we got around this annoying error. Your situation may vary and I am curious to see if this issue will be resolved in a future version of this particular WordPress theme.
One thought on “WordPress: Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.”