Results Bar – Title Length and Sku

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

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23952
    ptrc79
    ptrc79
    Participant

    I am trying to accomplish two things. I know I submitted this before, but my account seems to have been deactivated for some reason, so here it is again.

    1. Shorten the Product Name in the results bar
    2. Have the SKU Appear

    How do I do this?

    Peter

    #23968
    Ernest Marcinko
    Ernest 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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.