Home Forums WoodMart support forum class-widget-layered-nav.php

class-widget-layered-nav.php

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #73702

    rvk
    Participant

    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

    #73744

    Artem Temos
    Keymaster

    Hi,

    Thank you so much for reporting us. We will include these fixes in our next theme update.

    Regards

Viewing 2 posts - 1 through 2 (of 2 total)