Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • Hi! I want to do the same. I couldn’t because I can’t see the images and links of the needed modifications.
    Please repost.

    in reply to: Excerpt length and Read more / Blog post display #819110

    I have made some changes to get the full word. (not trim the word)

    // Excerpt length
    function custom_excerpt(){
    ?>
    <script>
    // trim sentence by 22 words
    	function trimByWord(sentence,wordcount = 22) {
    		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('.post-entry').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');

    Hope it help you all!
    Best

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