Category: Wordpress

  • LiteSpeed settings for SureCart

    I have been using SureCart for just over a year now. I have always had issues with LiteSpeed caching and the cart.

    Finally, a user in the SureCart Facebook group gave a clear list of settings to configure for SureCart with the LiteSpeed plugin for WordPress.

    Updated 01/2026

    The brief steps are:

    How to setup Litespeed cache for Surecart
    1. Under Cache -> Cache - set Cache REST API to OFF
    2. Under Cache -> Excludes - add the below under Do Not Cache URIs
    /wp-json
    /checkout
    /customer-dashboard
    /shop
    
    Optional:
    /login
    /wp-login
    /register
    /my-account
    /cart
    
    3. Under Cache -> Browser - set Browser Cache to OFF
    4. Under Page Optimization -> JS Settings - set JS Combine to OFF
    5. Under Page Optimization -> Tuning - add the below under JS Deferred / Delayed Excludes
    api-fetch.min.js
    a11y.min.js
    i18n.min.js
    url.min.js
    dom-ready.min.js
    hooks.min.js

    This is very important as you will get weird errors where cart items disappear, shop buttons don’t work etc.

    Complete LiteSpeed Cache Configuration for SureCart

    Step-by-Step Configuration Guide

    Follow these steps carefully to ensure SureCart works perfectly with LiteSpeed Cache.


    1. Cache Settings – Disable REST API Caching

    Navigation: LiteSpeed Cache → Cache → Cache

    Setting: Cache REST API Value: OFF

    Why: SureCart uses WordPress REST API for dynamic content (customer data, cart, checkout). Caching these requests causes outdated information and broken functionality.


    2. Cache Excludes – Exclude Dynamic Pages and API Routes

    Navigation: LiteSpeed Cache → Cache → Excludes

    Setting: Do Not Cache URIs Add these lines (one per line):

    /wp-json
    /checkout
    /customer-dashboard
    /shop

    Optional – Add if you have these pages:

    /login
    /register
    /my-account
    /cart

    Why: These pages contain user-specific, real-time data that should never be cached. Login and account pages need to display current user information.


    3. Browser Cache – Disable Browser Caching

    Navigation: LiteSpeed Cache → Cache → Browser

    Setting: Browser Cache Value: OFF

    Why: Aggressive browser caching can cause customers to see stale cart data, old prices, or outdated order information. This data cannot be cleared remotely, creating serious transaction issues.


    4. JavaScript Optimisation – Disable JS Combining

    Navigation: LiteSpeed Cache → Page Optimisation → JS Settings

    Setting: JS Combine Value: OFF

    Why: In HTTP/2 environments, combining JavaScript files is unnecessary and can break functionality. HTTP/2 allows parallel loading, making the combination redundant.


    5. Core WordPress Scripts – Prevent Deferring Critical Scripts

    Navigation: LiteSpeed Cache → Page Optimization → Tuning

    Setting: JS Deferred Excludes (or JS Delayed Excludes – add to both if both options exist)

    Add these scripts (one per line):

    api-fetch.min.js
    a11y.min.js
    i18n.min.js
    url.min.js
    dom-ready.min.js
    hooks.min.js

    Why: These core WordPress scripts are essential for dynamic functionality and accessibility. They must load synchronously. Deferring them breaks SureCart’s checkout, cart updates, and customer interactions.


    6. Save and Clear Cache

    After making all changes:

    1. Click Save Changes on each settings page
    2. Navigate to LiteSpeed Cache → Toolbox → Purge
    3. Click Purge All to clear all cached content
    4. Test your site thoroughly

    Testing Checklist

    After configuration, test these critical functions:

    • Add products to cart
    • Update cart quantities
    • Proceed to checkout
    • Complete a test order
    • Log into customer dashboard
    • View order history
    • Log out and log back in
    • Test on different browsers
    • Test in incognito/private mode

    Quick Reference Summary

    Setting LocationSetting NameValue
    Cache → CacheCache REST APIOFF
    Cache → ExcludesDo Not Cache URIs/wp-json, /checkout, /customer-dashboard, /shop
    Cache → BrowserBrowser CacheOFF
    Page Optimisation → TuningJS CombineOFF
    Page Optimization → TuningJS Deferred/Delayed Excludesapi-fetch.min.js, a11y.min.js, i18n.min.js, url.min.js, dom-ready.min.js, hooks.min.js

    Troubleshooting

    If checkout still doesn’t work:

    1. Clear LiteSpeed cache completely
    2. Clear your browser cache
    3. Test in incognito/private mode
    4. Check browser console for JavaScript errors

    If cart doesn’t update:

    1. Verify REST API caching is OFF
    2. Confirm /wp-json is in Do Not Cache URIs
    3. Clear all caches and test again

    If customer dashboard shows wrong data:

    1. Confirm /customer-dashboard is excluded from caching
    2. Verify Browser Cache is OFF
    3. Test after clearing all caches

    Additional Notes

    • HTTP/2: Modern hosting uses HTTP/2, which makes file combining obsolete
    • Cache Warmup: If using LiteSpeed’s cache warmup feature, ensure excluded pages aren’t included
    • Mobile Cache: If you have separate mobile cache enabled, these settings apply to both desktop and mobile
    • Testing: Always test thoroughly after changes, especially checkout and payment processing

  • All in One WP Migration Increase Upload Limit

    All In One WP Migration is one of the easiest plugins to use for migrating sites.

    I use it to test sites on different hosts.

    Unfortunately, in the free version, the upload is limited to 512MB.

    You can try to change the PHP settings in your host control panel, change the PHP max upload size and max post size.

    If you have version 6.77 (older version) you can quickly and safely modify the code in the Plugin Editor under Tools in the WordPress dashboard:

    Open the constants.php file and look for the following, at around line 250-300

    // =================
    // = Max File Size =
    // =================
    define( ‘AI1WM_MAX_FILE_SIZE’, 2 << 28 );

    Change it to

    define( 'AI1WM_MAX_FILE_SIZE', 536870912 * 20 ); 

    Update then go back to AIOWP plugin and you should get 10GB upload.

    Read this post for more details.

    Of course, support the plugin developer.

  • How to Fix WordPress upload directory not writable

    I migrated a WordPress site between VPS machines.

    I had an issue after the migration where this error was on my admin dashboard

    Unable to create directory uploads/2023/10. Is its parent directory writable by the server?

    I checked Site Health and confirmed that all other folder permissions were ok but the uploads directory was not writeable.

    I double-checked on my VPS and the folder was writeable.

    I finally found the solution and it was my error.

    I am using Server Avatar to manage my VPS and in the migration process, I unknowingly changed the migration directory case of the domain from xxxx to Xxxx.

    I logged into PHPMyAdmin, selected my WordPress website database table and selected the wp_options table. Located “upload_path” row and changed the casing of the path there, saved and it worked.

  • WordPress Admin Dashboard Corrupted – Simple Fix

    WordPress Admin Dashboard Corrupted – Simple Fix

    I recently had a site that I did not use or update regularly have the admin dashboard corrupted.

    There was no styling, only text jumbled up on the screen.

    It was impossible to navigate.

    I tried to clear the cache, disable the plugins folder via file manager/ftp but it did not work.

    I found this code to add to the wp-config.php file after WP_DEBUG line near the bottom

    define{'CONCATENATE_SCRIPTS', false);

    Add this and save and it should do the trick.

    The other option is to revert to PHP 8 or 7.4 if you are on 8.1 or 8.2.

  • The REST api encountered an unexpected result 404 WordPress Error

    I spend several hours over two days trying to figure out what this error was.

    I tried refreshing permalinks, deleting the .htaccess file and all sorts.

    In the end, I found this helpful post on the WordPress support forums.

    I narrowed the issue to a URL issue as it could not find the URL.

    From the post, the suggestion was to change the permalinks to custom and add:

    /index.php/%postname%/

    I did that, saved and it worked.

    The only issue now was every page had .index.php in front. I went back and changed to my standard permalinks setting “Post Name”, saved and now it works fine.

    The REST API encountered an error in WordPress when trying to retrieve data. The unexpected result returned by the REST API was a 404 error. This issue with the REST API in WordPress can be fixed by following some steps. Here’s how to resolve the REST API error in WordPress and prevent the REST API from encountering unexpected results.

    First, check if the REST API is enabled in your WordPress installation. To do this, navigate to the WordPress dashboard and go to the Settings tab. Under the Permalinks section, ensure that the “Post name” option is selected. If not, choose the “Post name” option and save the changes. This should enable the REST API and potentially fix the encountered error.

    If the REST API is already enabled and the error persists, it’s essential to troubleshoot further. One possible cause of the unexpected result with the REST API is a conflict with plugins or themes. To identify if this is the case, deactivate all your plugins and switch to a default WordPress theme. Then, try accessing the REST API again and check if the error still occurs. If the error disappears, it means that one of the deactivated plugins or the previously used theme was causing the unexpected result.

    To pinpoint the conflicting plugin or theme, reactivate them one by one and test the REST API after each activation. This will help you identify which specific plugin or theme is causing the error. Once the conflicting plugin or theme is identified, you can either reach out to its developer for support or search for alternative plugins/themes that don’t conflict with the REST API.

    By troubleshooting and resolving the encountered error in the REST API, you’ll ensure that your WordPress website functions smoothly. It’s crucial to stay vigilant and regularly check for updates to plugins and themes, as they can often introduce compatibility issues with the REST API. Keeping your WordPress installation up to date will help avoid unexpected results and maintain the proper functioning of the REST API.

  • WordPress code I always use on new installs

    WordPress code I always use on new installs

    I set up a lot of WordPress sites and I keep text files of the bits of code I add to the .htaccess file and config file on all new installs.

    To keep WordPress going smoothly, there are a few bits of code I add to files when I install WordPress on a new domain.

    Increase Memory Limit

    To increase the allowed memory size from the standard 40M to 256M I use the following code in wp-config.php (usually in the /public_html/ folder:

    define('WP_MEMORY_LIMIT', '256M');

    Replace the 256M with 96/128/256 but I find that 128M will suffice for most sites.

    Disable WP-Cron

    Until recently, I left the wp-cron to handle daily tasks with WordPress. I was advised by my hosts to switch to cPanel to handle cron jobs, this is more efficient and improves performance and reduces server load significantly.

    In the same file as before, wp-config.php enter the code below. I usually put it after the database collate information [define(‘DB_COLLATE’, ”);], don’t forget to save:

    define('DISABLE_WP_CRON', 'true');

    This will disable the wp-cron from running – you must enable the file to be run by your server. Login to your host backend, usually cPanel, click on Cron Jobs (Advanced section) and enter the command:

    /usr/local/bin/php ~/public_html/wp-cron.php >/dev/null 2>&1

    The first part /usr upto php depends on your host. They will usually have a post in their knowledgebase or you can message support for advice. The second part is the actual location of the wp-cron.php file. The >/dev/null 2>&1 just disables e-mail notifications, you will receive loads if left active.

    If like me, you install WordPress into the root directory then [username]/public_html/wp-cron.php should be fine. My host setup may differ to yours and I don’t need to specify the username.

    After you enter that, you can choose the times to run under common settings, my host suggested twice every hour, some suggest once an hour or once every 6 hours if you don’t have much traffic or make regular changes.

    For The Newsletter plugin I changed the frequency to once every 5 minutes as that is the recommended time for that plugin.

    Limit Post Revisions

    I found that I would have tens of revisions to a single post, all of these would be clogging up my database with useless data. To limit them just enter this code into wp-config.php

    define ('WP_POST_REVISIONS', 3);

    This will limit the maximum revisions to just 3 rather than loads and loads, 3-5 should be more than enough.

    SSL Redirect

    As all of my WordPress sites have SSL installed by default and I install to the base url without the www I add the following code to my .htaccess file to divert everything to the base url:

    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{HTTPS} off
     RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
     </IfModule>

    I made another post on this here where I had issues with icons

    Expires Headers for WordPress

    Add this to your .htaccess file (Apache server not Nginx) using the file manage in cPanel, click on settings and check show hidden files as files with a preceding . are usually hidden.

    <IfModule mod_expires.c>
      ExpiresActive On
    
      # Images
      ExpiresByType image/jpeg "access plus 1 year"
      ExpiresByType image/gif "access plus 1 year"
      ExpiresByType image/png "access plus 1 year"
      ExpiresByType image/webp "access plus 1 year"
      ExpiresByType image/svg+xml "access plus 1 year"
      ExpiresByType image/x-icon "access plus 1 year"
    
      # Video
      ExpiresByType video/webm "access plus 1 year"
      ExpiresByType video/mp4 "access plus 1 year"
      ExpiresByType video/mpeg "access plus 1 year"
    
      # Fonts
      ExpiresByType font/ttf "access plus 1 year"
      ExpiresByType font/otf "access plus 1 year"
      ExpiresByType font/woff "access plus 1 year"
      ExpiresByType font/woff2 "access plus 1 year"
      ExpiresByType application/font-woff "access plus 1 year"
    
      # CSS, JavaScript
      ExpiresByType text/css "access plus 1 month"
      ExpiresByType text/javascript "access plus 1 month"
      ExpiresByType application/javascript "access plus 1 month"
    
      # Others
      ExpiresByType application/pdf "access plus 1 month"
      ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
    </IfModule>

    Redis Password

    If you are having issues with Redis connections for server caching, you can manually enter the code into your wp-config.php file.

    Enter this code somewhere in the file.

    /** Redis Config **/
    define( 'WP_REDIS_PASSWORD', 'yourpasswordgoeshere' );

    I usually insert the password into the LiteSpeed Cache plugin but sometimes it does not connect so I enter the code into the wp-config.php file.

    Auto Update WordPress

    I prefer to let WordPress auto-update sites, sometimes the default is disabled.

    Just add this code to the wp-config.php file

    define( ‘AUTOMATIC_UPDATER_DISABLED’, false );
  • Instant Images for WordPress – server permissions

    Instant Images for WordPress – server permissions

    I read about a great plugin called Instant Images for WordPress that makes blogging a little easier.  A blog post without a featured images looks a little naked and unfinished.  Trawling around free images sites takes time, especially when you want to write a quick post and get it up asap.

    Instant Images is a free plugin that allows you to search and import images straight from the Unsplash.com royalty free image library.

    It has a few negative reviews but that is due to incorrect permissions on the image upload folder.  A very simple and quick fix.

    Simply use file manager or any FTP software, navigate to:

    public_html/wp-content/uploads/

    Click on the folder labelled instant-images and change the permissions from 3-4-1 to 7-5-5 – quick and easy and works great.

    Using the classic WordPress editor, there is a new button visible above the tools called Instant Images where you can quickly add images to a post.  Alternatively, you can go to the Media tab and add images there.

    There is a setting gear cog that allows you to set the dimensions which are very important as the images on Unsplash are very high resolution.

    Whatsapp gb 2021
  • CSV File issues fixed – MS Excel

    CSV File issues fixed – MS Excel

    I was working with a WordPress plugin and I needed to import a load of products, no problem there is a CSV import option.

    I tediously went through the products and entered them into a file, saved as CSV and uploaded.  Unfortunately, the file was not recognised as nothing was imported.

    I tried entering the encoding UTF-8 option but still no joy.

    Eventually, I found that saving the file as a MS DOS csv file in Excel and then uploading worked fine.

    I use Excel 365 but it should be the same for the previous versions.

  • WordPress MySQL error when switching to PHP 7.2 – Easy Fix

    WordPress MySQL error when switching to PHP 7.2 – Easy Fix

    I changed my PHP from 7.1 to 7.2 at my host Guru Cloud.  I noticed that my WordPress site was no longer working, I got the error:

    Your PHP installation appears to be missing the MySQL extension which is required by WordPress

    I switched back to 7.1 and it was working fine.  I searched around and found the easy fix.

    In cPanel, go to Select PHP Version and add the permission for mysqli and save.  After a refresh, the WordPress site was working fine.  I checked with my host, they said this was all that was required and will default that to the config for PHP 7.2.

    Watch this video for a quick demo on what to change.

     

  • WordPress icons distorted

    WordPress icons distorted

    I noticed an issue with some of my WordPress websites where the share icons and the search icon would be distorted.  I had been upgrading and changing themes, trying out new plugins and trying out Litespeed cache plugin as some of my sites are on a Litespeed server.

    The social share icons and search icons would sometimes become distorted and garbled, I tried various settings in Litespeed cache as when I switched this off, the icons were fine.  In the end I gave up and contacted the theme developer to see if they could help.

    After a few back and forth e-mails, the issue was the redirection to the HTTPS secure site, if the site URL was not HTTPS this caused an issue with the caching and icons.  I had to edit my .htaccess file in the public_html folder (view hidden files) and add the following code to create a 301 redirect:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>

    This has now rectified my issue and ensured that the secure site is always served,

Pin It on Pinterest