Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Excerpt length
- function custom_excerpt(){
- ?>
- <script>
- // trim sentence by 22 words
- function trimByWord(sentence,wordcount = 50) {
- var result = sentence;
- var resultArray = result.split(" ");
- if(resultArray.length > wordcount){
- resultArray = resultArray.slice(0, wordcount);
- result = resultArray.join(" ") + "...";
- }
- return result;
- }
- jQuery(window).load(function(){
- jQuery('.av-masonry-entry-content').each(function() {
- jQuery(".entry-content ").text(function(index, currentText) {
- return trimByWord(currentText);
- });
- jQuery(".entry-title a").text(function(index, currentText) {
- return trimByWord(currentText,15); // trim title by 15 words
- });
- });
- });
- </script>
- <?php
- }
- add_action('wp_head', 'custom_excerpt');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement