The post WordPress Fix Plugin Cache Directory Issues, WP Super Cache appeared first on Andrew.Technology.
]]>
This guide covers issues with WordPress cache plugins and site migration. By default WordPress doesn’t have it’s own caching system. Popular plugins for this are W3 Total Cache, WP Super Cache, and WP Fastest Cache. The basics of how each plugin handles caching is similar enough. This guide is going to cover WP Super Cache but should be relevant for all.
This issue occurred when I was migrating my site. I was moving my WordPress install from one server to another. The operating system, directory structure, and files were exactly the same as before. This particular move involved going from one cPanel server to another. For this guide, I will use example.com for the domain and /home/example/public/ for the directory.
Because the server was setup exactly the same, I just assumed it would work. I’ve done many WordPress installs and migrations. Each one was relatively similar. Take a full backup of the site, including all files and databases. Then copy the files and database to the new server. Update the wp-config.php file to use the new database settings. And poof, you’ve got a copy of your site.
This time, everything worked from my WordPress migration, except the cache plugin. WP Super Cache showed the error, “Error: Your cache directory (/home/example/public/wp-content) did not exist and couldn’t be created by the web server.” Then it recommends checking the permissions. Ending the message with “Cannot continue… fix previous problems and retry.” So of course, the first thing I did was update the permissions.
At this point, please please take a backup of your site. If you’ve got automatic backup, then good job and skip down to Change File Permissions. If not, please take a manual backup at this time. It’s good practice to regularly backup your website files and database. All the content of your WordPress site is valuable! Also, if something goes wrong you can easily revert to a backup. You’ve been warned!

WP Super Cache Error: Your cache directory /home/example/public/wp-content did not exist. Cannot continue… fix previous problems and retry.
You need software installed to access the files of your WordPress site. I prefer to use FileZilla for my (S)FTP needs but any FTP client will work. Using (S)FTP software, navigate to where your WordPress site is installed. For the example its /home/example/public. This is the root of my example site. Your root will be different. It’s where all the files for your WordPress site are located.
Once you’re at the site root, right click the “wp-content” folder. A drop down menu appears. At the bottom of the list is “File permissions…”, click that. A new permissions box pops up. In the Numeric value input type: 775. Then Check “Recurse into subdirectories.” Under that pick the ratio “Apply to directories only.” Finally, hit OK. Wait for it to finish, which could take longer depending how big your site is.
Here is the breakdown of actions we just did. I’m also going to include the commands in case you want to do this using SSH. That is more advanced though, so ignore those commands if you are inexperienced:
The last step takes longer depending on how many folders are stored under wp-content. In other words, if you’ve got a log of plugins or media library uploads. It has to read all the directories and change each one. The console of your FTP client will scroll telling you this information. Once it’s done scrolling, you’ve successfully changed all the permissions.
Just changing permissions did not work for me. I had to do some other tweaking to my WordPress install. Upon researching the topic, many suggested updating two files. They suggest modifying the wp-cache-config.php and advanced-cache.php files. But, this is only helpful if you’ve changed the file structure. Perhaps, you moved to a new hosting provider and they use a different file structure than you’re previous. Like in the the example root. It would go from /home/example/public to /var/www/example/public. If this is the case for you, then follow these steps, if not jump down to Deleting wp-cache-config.php & advanced-cache.php Files.
In theory this could fix the issue. Refresh the WordPress admin. If the cache plugin error is gone, then congrats your WP cache plugin is fixed. If the error priests, then keeping reading.
This is the last solution to fix a WordPress cache plugin problem. You’ve gone through all the other steps. You’ve changed the permissions of the wp-content folder. Your new server is setup exactly the same as the old. Essentially, your file structure did not change in the migration like myself. Then follow these steps:
Basically, we are turning the caching plugin off. Deleting the common cache files: wp-cache-config.php and advanced-cache.php. Then, turning the same WP cache plugin back on. Reactiving the cache plugin recreates those common files.
The wp-cache-config.php & advanced-cache.php will be brand new. The cache settings will be changed to the defaults. Obviously, you’ll need to update your cache settings. But, deleting those files is what fixed my problems. Following these final steps eliminated the WP Super Cache error from my admin. Once I got my cache settings back to my liking and poof everything my WordPress caching plugin worked again. Feels good.
Let me know in the comments if this worked for you! Thank you for reading.
The post WordPress Fix Plugin Cache Directory Issues, WP Super Cache appeared first on Andrew.Technology.
]]>The post Fixing WordPress Sitemap.xml Error on Line at Column appeared first on Andrew.Technology.
]]>
WordPress sitemap.xml: This page contains the following errors: error on line 3 at column 6: XML declaration allowed only at the start of the document
Working on a WordPress site I kept seeing this error on my sitemap.xml “This page contains the following errors: error on line 3 at column 6: XML declaration allowed only at the start of the document” which basically messed up the sitemap producing invalid XML. I was using a plugin to generate the sitemap, Google XML Sitemaps, so at first I thought that might be the issue so I tested another one, Better WordPress Google XML Sitemaps, but it was also messed up with the same error.
I’ve been working on a number of WordPress sites using this same plugin without seeing this error so I pulled up some working sitemaps along with the broken version. A quick comparison of the source code for each sitemap.xml and I immediately noticed the culprit at the top of the broken sitemap there where two blank blank lines aka white space at the very top. We know this is the issue because the error specifially mentions line 3 which is the first line after the white space ends. Check out my screenshot of the XML source:
A search of the Google and I quickly found multiple posts discussing the issue. It’s not just the sitemap that is messed up but all of the XML generated by WordPress like RSS feeds. Most recommend activating a different theme (like Twenty Fifteen or any that come by default) and disable plugins to try to find what is creating the white space. Honestly, that might work for some but I was using the same base theme and plugin on a different site with the sitemap.xml working so I did not want to waste time with that.
Most forum discussions lead to a 2010 blog post: WordPress Remove Blank Line From RSS Feed – wordpress error on line 2 at column 6: XML declaration allowed only at the start of the document. I recommend reading this post to learn more about this issue because it’s well written and informative but it’s not very up to date so I had to modify the directions a bit to get it working on modern WordPress.
Basically you need to download a small PHP script/file called wejnswpwhitespacefix.php and include that in your WordPress. The original post includes the script at the top of the index.php file but that did not actually work for me on WordPress version 4.2.5 so that original method may not work anymore for latest versions. Plus, adding it to index.php is not the best place because that gets updated for new version of WordPress so you would have to make the change each time you update the core. Some people had also commented down that page that the index.php method was not working for 4.0 so I recommend using the alternate version below.
I added the file wejnswpwhitespacefix.php to my theme folder and then included it using my theme’s functions.php file. Every WordPress theme should have this file with code already in it most likely so all you need to do is add this one line at the very top of the file functions.php right under the <?php tag:
<?php
include("wejnswpwhitespacefix.php");
//the rest of the functions.php like before below, the original code already in it
Save that and you’re done! Make sure the wejnswpwhitespacefix.php and your functions.php are in the same folder else you will need to change the path to that file. Now hitting refresh the sitemap.xml works along with RSS feeds and any other XML WordPress generates! Here is a screenshot of the valid XML from this very site sans the white space at top like it should be.
The post Fixing WordPress Sitemap.xml Error on Line at Column appeared first on Andrew.Technology.
]]>