Ajax Load More Logo
Developer documentation for the Ajax Load More Cache add-on.
The Ajax Load More cache can be auto-generated by populating the alm_cache_array filter with an array of cache URLs and IDs.
The alm_cache_array filter let’s Ajax Load More know which cache instances should be auto-generated when the build is initiated.
The following array parameters are available for each cache item – url and id are required fields for each.
Before the cache is auto-generated, the current Ajax Load More cache is emptied – this means even cache instances that are not set to be auto-generated will be cleared.
Note: The Ajax Load More cache is not built on it’s own, it requires you to initiate the build process from the WordPress admin.
To start the cache build process, you’ll need to visit the Ajax Load More Cache page in your WordPress admin and click the Generate Cache button in the sidebar.
Once initiated, you will be redirected to a new page (as shown above) where you can track the cache progress and status.
Note: If you exit the page while auto-generating the cache, the process will stop where you exited.
The following filter hooks are available when using this add-on:
The alm_cache_created action is triggered after a cache file has been created.
The alm_cache_deleted action is triggered after an individual cache file or the entire ALM cache has been deleted.
The alm_cache_path filter can be used to update the absolute server path of the Ajax Load More Cache – this path is used when writing and saving files to your server.
The following snippet will adjust the default cache path to a /cache/ folder in the current theme directory.
NOTE: When filtering the cache location you must update both alm_cache_path and alm_cache_url hooks.
The alm_cache_url filter can be used to update the URL path to the Ajax Load More Cache – this URL is used when rendering the cached content of an Ajax Load More query.
The following snippet will adjust the default cache URL to a /cache/ folder in the current theme directory.
NOTE: When filtering the cache URL you must update both alm_cache_path and alm_cache_url hooks.
The alm_clear_cache action can be used by authenticated users to clear the full Ajax Load More cache or by a specific cache ID.
In some instances you will be required need to create the cache_id dynamically. In the case of taxonomy archives (category.php, tag.php) or when filtering by a querystring the cache_id should be generated on the fly to avoid issues with cache duplication.
The following example uses the current taxonomy and slug to create a unique cache_id for an archive template.
The following example parses the URL querystring of a WooCommerce shop to create a unique cache_id for sorted products.
« Back to Add-ons