• Resolved debruning

    (@debruning)


    Hi there,

    We have built a fairly in-depth category system to manage our products.
    If we do a search for drill bits for example, 10 categories are returned, but we need to be able to control that number….it should be 30 minimum.

    I have also read that parent categories are excluded from the results, that would be a great option to be able to toggle on/off.

    We’re currently evaluating if your plugin can do all the things we need, so far with the above exceptions it’s been great. If we can get those sorted out we’ll be purchasing the premium licence asap.

    Hope to hear from you soon and have a great week,

    David

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    So to show maximum 30 categories inside search results please use following code snippet:

    add_filter( 'aws_search_terms_number', 'my_aws_search_terms_number' );
    function my_aws_search_terms_number( $number ) {
        return 30;
    }

    About parent categories – you can try to use following code snippet:

    add_filter( 'aws_search_tax_results', 'aws_search_tax_results_ds', 10, 2 );
    function aws_search_tax_results_ds( $result_array, $taxonomy ) {
        if ( isset( $result_array['product_cat'] ) && ! empty( $result_array['product_cat'] ) ) {
            $parent_terms = array();
            foreach ( $result_array['product_cat'] as $key => $cat ) {
                $term = get_term( $cat['id'], 'product_cat' );
                if ( ! is_wp_error( $term ) && ! empty( $term ) ) {
                    if ( $term->parent ) {
                        $parent_term = get_term( $term->parent, 'product_cat' );
                        $parent_terms[$parent_term->term_id] = array(
                            'name'     => $parent_term->name,
                            'id'       => $parent_term->term_id,
                            'count'    => $parent_term->count,
                            'link'     => get_term_link( $parent_term ),
                            'image'    => ''
                        );
                    }
                }
            }
            foreach ( $parent_terms as $parent_term_item ) {
                array_unshift( $result_array['product_cat'], $parent_term_item );
            }
        }
        return $result_array;
    }

    After adding these code snippets please open plugins settings page and click ‘Clear cache’ button.

    Regards

Viewing 1 replies (of 1 total)
  • The topic ‘How to increase number of categories displayed in results?’ is closed to new replies.