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 3 years, 6 months ago.
- AuthorPosts
- September 12, 2019 at 8:54 pm #23952
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 AppearHow do I do this?
Peter
September 13, 2019 at 1:17 pm #23968Hi 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 :)
- AuthorPosts
You must be logged in to reply to this topic.