This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Results Bar – Title Length and Sku

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Results Bar – Title Length and Sku Reply To: Results Bar – Title Length and Sku

#23968
Ernest MarcinkoErnest Marcinko
Keymaster

Hi Peter,

Sorry about that, there was a major data loss on our server, and we could only restore 30+ day old backup copy.

1. The title length is not altered by the plugin, but you can use a custom code to change that to any length you want to. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

add_filter( 'asp_results', 'asp_limit_title_length', 10, 1);
function asp_limit_title_length( $results ) {
  $limit = 120;
  $end = '...';
  // -------------------------------------------
  
  foreach ($results as &$r) {
    if ( strlen($r->title) > $limit ) {
      $new = wd_substr_at_word($r->title, $limit);
      if ( $new != $r->title )
        $r->title = $new . $end;
    }
  }
  
  return $results;  
}

2. To display the SKU, use the advanced title & content fields feature. That allows displaying a custom field value within the contents, in your case the ‘_sku’ custom field.