Tagged: Latest News, sidebar, Widget
-
AuthorPosts
-
November 25, 2020 at 3:01 pm #1263010
Hello everyone,
I want to reduce the Excerpt length of the Enfold Latest-News Sidebar Widget und put a “read more” link under it, that links to the respective blog post. I tried various recommended solutions, like PHP Snippets or installing the “Advanced Excerpt Plugin”. Sadly nothing seems to work. Can you please help me?Thanks in advance.
JulianNovember 26, 2020 at 1:09 pm #1263250Can somebody help?
November 26, 2020 at 5:19 pm #1263299well there is a more complex way of having a substituted edited : class-framework-widgets.php
on that it will be possible to have the Read more insert translatable with avia_framework.but a fast way is to put this in child-theme functions.php:
on my opinion it will be better to shorten the amount of words in that excerpt than to have letter shortening.function custom_news_excerpt(){ ?> <script> (function($){ function trimByWord(sentence,wordcount = 5) { var result = sentence; var resultArray = result.split(" "); if(resultArray.length > wordcount){ resultArray = resultArray.slice(0, wordcount); result = resultArray.join(" "); } return result; } $(document).ready(function(){ $('.news-content').each(function() { var newsLink = $(this).find('.news-link').attr('href'); $(this).find('.news-excerpt').text(function(index, currentText) { return trimByWord(currentText); }); $(this).find('.news-excerpt').append('<div class="read-more-link"><a class="more-link" href="'+newsLink+'">Read more<span class="more-link-arrow"></span></a></div>'); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_news_excerpt');
November 26, 2020 at 5:35 pm #1263307here is the edited class-framework-widgets.php
see lines 1020ff
Pastebin Linkthen you only need the excerpt shortener in additon to this:
function custom_news_excerpt(){ ?> <script> (function($){ function trimByWord(sentence,wordcount = 5) { var result = sentence; var resultArray = result.split(" "); if(resultArray.length > wordcount){ resultArray = resultArray.slice(0, wordcount); result = resultArray.join(" "); } return result; } $(document).ready(function(){ $('.news-content').each(function() { var newsLink = $(this).find('.news-link').attr('href'); $(this).find('.news-excerpt').text(function(index, currentText) { return trimByWord(currentText); }); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_news_excerpt');
-
AuthorPosts
- You must be logged in to reply to this topic.