HUSKY - WooCommerce Products Filter Professional

Botoscope is currently in early access

Category Description Not Showing on Filtered Shop Page

By default, WooCommerce displays category descriptions on archive (category) pages. However, when the HUSKY product filter is active, the shop page URL changes from a true category archive to a filtered shop page — for example, /shop/?swoof=1&product_cat=my-category. On this type of page, WordPress does not load the taxonomy object, so any code that relies on is_product_taxonomy() will not find a category and the description will not be displayed.

This is expected WordPress behavior and is not a bug in HUSKY.

To display the category description on the filtered shop page, add the following snippet to your theme’s functions.php file or via a code snippets plugin:

add_action('woocommerce_before_shop_loop', function() {

    // Exit if this is a normal category page without WOOF filter
    if (is_product_taxonomy() AND empty($_GET['swoof'])) return;

    $term = null;

    // Try to get term from taxonomy archive
    if (is_product_taxonomy()) {
        $term = get_queried_object();
    }

    // If not found, try HUSKY's really_curr_tax parameter
    if ((!$term || is_wp_error($term)) AND !empty($_GET['really_curr_tax'])) {
        $raw     = sanitize_text_field($_GET['really_curr_tax']);
        $term_id = (int) explode('-', $raw)[0];
        if ($term_id > 0) {
            $term = get_term($term_id, 'product_cat');
        }
    }

    // Exit if term not found or has no description
    if (!$term || is_wp_error($term) || empty($term->description)) return;

    echo '<div class="term-description">';
    echo do_shortcode(wp_kses_post(wpautop($term->description)));
    echo '</div>';

}, 5);

This snippet reads the current category from the really_curr_tax parameter that HUSKY passes in the URL and manually outputs the description before the product loop.

Note: styling of the .term-description block depends on your theme.

Ref: https://pluginus.net/support/topic/husky-products-filter-professional-for-woocommerce-solution


Troubles? Ask for Support!