Forum Replies Created

Viewing 1 replies (of 1 total)
  • I’ve faced a problem: Translate the product category breadcrumbs.

    This is how i’ve solved this:

    add_filter("woocommerce_breadcrumb_main_term", "theme_woocommerce_breadcrumb_main_term", 11, 2);
    
    function theme_woocommerce_breadcrumb_main_term($main, $terms) {
        $current_lang = pll_current_language();
        if ($current_lang) {
            foreach ($terms as $term) {
                $term_id = $term->term_id;
                $lang = pll_get_term_language($term_id);
                if ($lang === $current_lang) {
                    $main = $term;
                    break;
                }
            }
        }
        return $main;
    }
    • This reply was modified 5 years, 7 months ago by buutqn.
Viewing 1 replies (of 1 total)