get_Id(), 'rank_math_primary_category', true ); if ( $primary_cat_id ) { $product_cat = get_term( $primary_cat_id, 'product_cat' ); $primary_term = $product_cat->name; } if ( ! empty( $primary_term ) ) { return $primary_term; } return $term; } /** * Retrieve primary product term ID, set through Rank Math. * * @param string $term The original term string. * @param \WC_Product $product Product. * * @return int|string */ public function get_primary_term_id( $term, $product ) { $primary_term_id = get_post_meta( $product->get_Id(), 'rank_math_primary_product_cat', true ); if ( ! empty( $primary_term_id ) ) { return $primary_term_id; } return $term; } /** * Rank Math breadcrumbs. * * @param string|array $class One or more classes to add to the class list. * @param bool $display Whether to display the breadcrumb (true) or return it (false). * * @return string|void The breadcrumbs if $display set to false. */ public function rank_math_breadcrumb( $class = '', $display = true ) { if ( function_exists( 'rank_math_the_breadcrumbs' ) && function_exists( 'rank_math_get_breadcrumbs' ) ) { $args = array(); $classes = is_array( $class ) ? $class : array_map( 'trim', explode( ' ', $class ) ); $classes[] = 'rank-math-breadcrumb'; $classes[] = 'breadcrumbs'; $classes[] = get_theme_mod( 'breadcrumb_case', 'uppercase' ); $classes = array_unique( array_filter( $classes ) ); $classes = implode( ' ', $classes ); $args['wrap_before'] = '