Advertise with Googlier.com PHP – Andrew.Technology https://andrew.technology Technology, hardware, software, and everything in between Wed, 21 Nov 2018 06:01:52 +0000 en-US hourly 1 https://wordpress.org/?v=5.4.25 WordPress Fix Plugin Cache Directory Issues, WP Super Cache https://andrew.technology/wordpress-fix-super-cache-plugin-issues/ https://andrew.technology/wordpress-fix-super-cache-plugin-issues/#respond Mon, 19 Nov 2018 22:32:20 +0000 http://3.128.157.198/?p=1370 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…

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.

WP Super Cache Error: Your cache directory /home/example/public/wp-content did not exist. Cannot continue… fix previous problems and retry.

Change File Permissions for WordPress wp-content Folder

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:

  • Change directory to the root /home/example/public – cd /home/example/public
  • Set permissions of /home/example/public/wp-content –  chmod 755 wp-content
  • Set permissions of all directories bellow wp-content folder –  chmod 755 -R wp-content (added recursive command, you could just run this instead of previous command)

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.

Updating wp-cache-config.php & advanced-cache.php Files to Fix WP Super Cache

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.

  • Navigate to your WordPress site root and then the wp-content directory
  • Copy the wp-cache-config.php & advanced-cache.php files to your local computer
  • Open both files in a text editor
  • Search for the old WordPress install directory, like for example /var/www/example/public
  • If you got search hits for this then you do actually need to update to your new server’s file path. If you go no hits then go to the last step, Deleting wp-cache-config.php & advanced-cache.php Files.
  • Use find and replace functionality. Search for your old site’s structure and replace with the new. For example, search for “/var/www/example/public” and replace with “/home/example/public”. Save both files.
  • Upload them back to your server using (S)FTP.

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.

Deleting wp-cache-config.php & advanced-cache.php Files to Fix WordPress Cache Plugin

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:

  • First, disable your cache plugin from the WordPress admin. In my case it’s WP Super Cache. Just search for the word “cache” if you’re not sure and disable that plugin.
  • Using FileZilla, or any (S)FTP account, navigate to the wp-content folder. Then, delete wp-cache-config.php and advanced-cache.php files.
  • Refresh your (S)FTP client to double check those files are gone.
  • Refresh your WordPress site or admin section.
  • Last, enable your cache plugin again. Like WP Super Cache, W3 Total Cache, WP Fastest Cache, etc..
WordPress admin plugins with WP Super Cache highlighted

WordPress admin plugins with WP Super Cache highlighted

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.

]]>
https://andrew.technology/wordpress-fix-super-cache-plugin-issues/feed/ 0
Fixing WordPress Sitemap.xml Error on Line at Column https://andrew.technology/fixing-wordpress-sitemap-xml-error-on-line-at-column/ https://andrew.technology/fixing-wordpress-sitemap-xml-error-on-line-at-column/#respond Wed, 16 Sep 2015 22:15:24 +0000 http://3.128.157.198/?p=385 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 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

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:

WordPress sitemap.xml white space at top

WordPress sitemap.xml white space at top

Fixing the WordPress white space issue above XML

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.

Include the script wejnswpwhitespacefix.php into your theme’s functions.php

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.

WordPress sitemap.xml valid not white space

WordPress sitemap.xml valid wihout white space http://3.128.157.198/sitemap.xml

The post Fixing WordPress Sitemap.xml Error on Line at Column appeared first on Andrew.Technology.

]]>
https://andrew.technology/fixing-wordpress-sitemap-xml-error-on-line-at-column/feed/ 0