Tagged: read more
-
AuthorPosts
-
August 13, 2017 at 2:42 pm #838228
I have an image where you can click and you will get a list of a particular category ( Pages and posts)
I have used this code below to trim the length of the Page or Post.What I would like to add is a Read More link at the bottom of this to anyone can go to the page or page they see listed.
Can this be done??
code is
// Excerpt length function custom_excerpt(){ ?> <script> // trim sentence by 150 words function trimByWord(sentence,wordcount = 150) { 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');
Thanks
August 13, 2017 at 10:09 pm #838352Hey wealthyone,
I think you can add/insert the read more link after the … in your code:
result = resultArray.join(" ") + "...";
Hope this helps.
Best regards,
NikkoAugust 14, 2017 at 11:23 am #838557Thanks. But what is the code for the Read More link?
So when lots of posts and pages are shown, then what code will grab the link for each.thanks
August 14, 2017 at 3:58 pm #838720Hi wealthyone,
Could you please give us a link to your website, we need more context to be able to help you.
Best regards,
VictoriaAugust 14, 2017 at 11:38 pm #839014its a dev site on my desktop.
I have an image that when clicked will list a all of one category.
When this list came up, it would show the full post, but adding code above reduced that to set number of words.
All I would like to do is add an option to have “Read More” at the end of each listed post and then click that link and it takes
you to the actual post itself.Pages are also set up with categories so pages get listed as well.
If there is a whole bunch of new code that will do that same then I could try that. But I can not find anything else
thanks
August 17, 2017 at 2:45 pm #840418Hi wealthyone,
We need to see the actual css and html to be able to propose a solution for you. Please get back to us when you get the website to some testing server.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.