Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/jcs-company-work/advanced-search/archive/refs/heads/main.zipAdvanced Search (ESAS) Plugin
Description
Advanced Search (ESAS) is a WordPress plugin that enhances product grids with dynamic filtering, live search, pagination, and grouped product support.
It consists of two main parts:
-
Backend API – provides a custom REST endpoint at
/custom/v1/es-advanced-search/returning JSON data for tiles. Supports optional filtering bycategoryoreffect. Uses caching via WordPress transients for performance. Automatically clears cache when batch posts are saved, trashed, or deleted. -
Frontend JS – the
TileFilterclass handles live filtering, search, pagination, grouped products, and URL state management. Tiles update in real-time with counts for grouped products.
Key Features:
- Multi-filter group support with live search
- Pagination that adapts to device width
- Supports grouped products / child batch tiles
- Maintains filter and pagination state in URL hash
- Reset button fully resets filters, pagination, and tile counts
- Backend API caching ensures fast responses and reduces server load
- WooCommerce and ACF integrated for batch/product data
Installation
- Upload the
advanced-searchplugin folder to/wp-content/plugins/. - Activate the plugin via the WordPress Plugins menu.
- Ensure your product grid page includes the required HTML structure and classes for filters and tiles.
Usage
- Use the
[tilefilter_grid]shortcode (replace with your actual shortcode) to display a product tile grid. - Frontend filter buttons require
.controlclass withdata-toggleanddata-filter-group. - Live search input requires
.live-filter. - Reset button requires
#reset-filters.
The frontend automatically initializes the TileFilter JS class. Filters, pagination, and grouped product counts update dynamically.
Backend API
ESAS_Batches_API
Provides a REST API endpoint for fetching batch products.
- Endpoint:
/custom/v1/es-advanced-search/ - Method:
GET - Optional query parameters:
category– filter by categoryeffect– filter by effect
Caching:
- API results are stored in a transient (
esas_products_json) for speed. - Cache is cleared automatically when relevant batch posts are saved, trashed, or deleted.
- Development: 10-minute cache; Production: 30-day cache.
Data Returned (per batch/product):
id,title,price,quantity,imageeffects,colour,finish,thickness,sizesfactory,menu_order
All string fields are normalized to lowercase for frontend filtering.
Initialization & Hooks
init()– registers REST routes and hooks intosave_post_batch,trashed_post,deleted_postto clear cache.get_all_batches(WP_REST_Request $request)– main callback, returns cached or freshly built JSON.build_batches($category = null, $effect = null)– prepares batch data for API.get_query_args($category, $effect)– constructs WP_Query arguments.get_batch_data($batch_id)– fetches product + ACF data, prepares normalized JSON.
Frontend JS (TileFilter)
- Initializes on page load.
- Filters and paginates tiles dynamically based on
activeFiltersandactiveItems. - Live text search updates filter state in real-time.
- Child tiles of grouped products are automatically shown/hidden.
- URL hash reflects current filter and pagination state for sharing/bookmarking.
- Reset button clears filters and search, updates all tile visibility and counts.
Dependencies
- Vanilla JavaScript (ES6 compatible)
- WooCommerce + ACF (for batch/product data)
Changelog
1.0.0
- Initial release with backend API, caching, dynamic tile filtering, live search, grouped product support, and pagination.
License
GPLv2 or later