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

  • Resolved agunda



    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?:
    (First is LAFAYETTE, then JVC then TELETON)

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

    Best regards

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


    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.

    Thread Starter agunda


    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!

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