Remove text after a dot and a colon in Woocommerce product title

Question

In my product title, I would like to remove all the text content after the first dot “.” or colon “:”.

For instance I would like to transform :
Theodore Deck : The Peter Marino Collection => Theodore Deck

I tried this code from this articlebut without success.

function explode_parts($title, $id){
    $parts = explode(' : ', $title);
    $before = $parts[0]; //before the :
    $after = $parts[1]; //after the : 
    return (whatever);
}

add_filter('the_title', 'explode_parts');

Thanks for your help!

0
, , Pardaigle 3 years 2020-06-08T05:10:28-05:00 0 Answers 83 views 0

Leave an answer

Browse
Browse