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

Results Bar – Title Length and Sku

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23952
    ptrc79ptrc79
    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 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.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.