Knowledge Base

How to remove ‘Variation #xyz of’ from product variation title

in Ajax Search Pro Tips

WooCommerce automatically adds the ‘Variation #123 of’ to the title of the product variation result.

To remove this annoying string from the title, add this code to your themes functions.php file:

add_filter( 'asp_results', 'asp_product_variation_fix', 1, 1 );

function asp_product_variation_fix( $results ) {
  foreach ($results as $k=>$v) {
    // Modify the post title
    $results[$k]->title  = preg_replace("/(Variation) \#(\d+) (of)/si", '', $results[$k]->title);

  return $results;