Support » Plugin: Relevanssi - A Better Search » Search results should display child category

  • Resolved agunda

    (@agunda)


    Hi!

    I really like this plugin very much but miss a feature:
    The search results show the title of the product, but what I still need is the child category in advance, so that the search result is ambiguous.
    Is that feasible?: https://mrstylus.com/?s=mc+200&post_type=product
    (First is LAFAYETTE, then JVC then TELETON)

    Many thanks for the support and also many thanks for this great plugin!

    Best regards
    Chriss

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    That’s up to your theme. You need to edit your search results template to show the child categories. Since you’re using a premium theme, the right place to ask about this is the theme support.

    Hi Mikko,
    thanks for opening my eyes 🙂
    For the others who need it, in #childtheme/functions.php:

    /**
     * AGUNDA show last child category on woocommerce search result page
     */
    function category_single_product(){
        $product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
        if ( $product_cats && ! is_wp_error ( $product_cats ) ){
            $single_cat = array_pop( $product_cats ); ?>
            <h3 itemprop="name" class="product_category_title"><span><?php echo $single_cat->name; ?></span></h3>
    <?php }
    }
    add_action( 'woocommerce_before_shop_loop_item_title', 'category_single_product', 25 );

    Thanks a lot!
    Chriss

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search results should display child category’ is closed to new replies.