Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. //Excerpt length
  2. function custom_excerpt(){
  3. ?>
  4. <script>
  5. // trim sentence by 22 words
  6. function trimByWord(sentence,wordcount = 50) {
  7. var result = sentence;
  8. var resultArray = result.split(" ");
  9. if(resultArray.length > wordcount){
  10. resultArray = resultArray.slice(0, wordcount);
  11. result = resultArray.join(" ") + "...";
  12. }
  13. return result;
  14. }
  15. jQuery(window).load(function(){
  16. jQuery('.av-masonry-entry-content').each(function() {
  17. jQuery(".entry-content ").text(function(index, currentText) {
  18.  
  19. return trimByWord(currentText);
  20.  
  21. });
  22. jQuery(".entry-title a").text(function(index, currentText) {
  23. return trimByWord(currentText,15); // trim title by 15 words
  24. });
  25. });
  26. });
  27. </script>
  28. <?php
  29. }
  30. add_action('wp_head', 'custom_excerpt');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement