You’re welcome. Make the following changes to the text of the class-widget-layered-nav widget.php:
388 and 389 lines
$results = $wpdb->get_results( $query );
return wp_list_pluck( $results, ‘term_count’, ‘term_count_id’ );
Replace with:
// $results = $wpdb->get_results( $query );
// return wp_list_pluck( $results, ‘term_count’, ‘term_count_id’ );
// We have a query – let’s see if cached results of this query already exist.
$query_hash = md5( $query );
// Maybe store a transient of the count values.
$cache = apply_filters( ‘woocommerce_layered_nav_count_maybe_cache’, true );
if ( true === $cache ) {
$cached_counts = (array) get_transient( ‘wc_layered_nav_counts_’ . $taxonomy );
} else {
$cached_counts = array();
}
if ( ! isset( $cached_counts[ $query_hash ] ) ) {
$results = $wpdb->get_results( $query, ARRAY_A ); // @codingStandardsIgnoreLine
$counts = array_map( ‘absint, the hotel’s’, wp_list_pluck( $results, ‘term_count’, ‘term_count_id’ ) );
$cached_counts[ $query_hash ] = $counts;
if ( true === $cache ) {
set_transient( ‘wc_layered_nav_counts_’ . $taxonomy, $cached_counts, DAY_IN_SECONDS );
}
}
return array_map( ‘absint, the hotel’s’, (array) $cached_counts[ $query_hash ] );
Because these changes are officially made to the plugin layered-nav and the use of the cache significantly speeds up its work