Friday, August 5, 2022
HomeWordPress DevelopmentTake away SKU on the finish of product titles (Woocommerce)

Take away SKU on the finish of product titles (Woocommerce)


I am attempting to take away SKU on the finish of my product titles (e.g. “Good product DFO314” the place DFO314 is a SKU and they’re all totally different for every product). What I’ve tried:

operate sku_product__title($title, $id) {
    world $pagenow;
    if ( $pagenow != 'edit.php' && get_post_type( $id ) == 'product' ) {
        if(preg_match('/[^(C375|C377|C378|C379|C380|C381|C382|C383|C385|C386|C387|C388|C389|C390|C434|C435|C436|C437|C438|C439|C440|C441|C442|C443|C444|C445|C446|C447|C448|C449|C450|C451|C461|C462|C463|C464|C465|C466|C467|C468|C469|C470|C471|C472|C473|C474|C475|C476|C477|C478|C480|C481|C482|C483|C484|C485|C486|C487|C488|C489|C490|C491|C492|C493|C494|C495|C496|C497|C498|C500|C501|C502|C504|C505|C507|C509|C510|C511|C512|C513|C514|C515|C517|C518|C520|C521|C522|C525|C528|C529|C530|C531|C532|C533|C534|C535|C536|C538|C539|C540|C542|C543|C545|C546|and so on)]*/', $title, $matches)){
            return trim($matches[0]);
        }else{
            return $title;
        }
    }
    return $title;
}
add_filter('the_title', 'sku_product__title', 10, 2);

Nevertheless it removes each phrase with matching letters that’s not what I on the lookout for. What to vary on this code to take away solely SKU as an entire and go away clear title?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments