• At the moment my post excerpt on the homepage is automatically at around 80 words..Therefore it takes up too much of the page.
    How can I edit this default so that all post excerpts on the homepage have less words? Ie around 30.
    Also an edit would be good that would still be there should a future update of Nisarg occur.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • I believe an excerpt length of 80 characters is the WordPress default, irrespective of theme used.

    You could attempt to change your WordPress settings via WP Dashboard -> Settings -> Reading to display “Full Post” rather than “Excerpt” and then experiment with inserting a custom “Read More” tag in the body of each post where you wanted the excerpt or teaser to end. You can do this via the standard WP Post Editor using the “Read More” button in the text formatting options list.

    The option I used for slightly more control was to download the Advanced Excerpt WordPress plugin . I preferred this solution as it provides options to change the automatically assigned excerpt length to a given character limit without needing to set custom “Read More” tags for each post, while also allowing you to customize the length of the excerpt or teaser for a given post if needed by inserting a “Read More” tag. Best of both worlds.

    The plugin also enables you to refine your automatically-defined excerpts by ending them not at a given character limit, which can awkwardly interrupt both words and sentences, but also by ending them at the end of a word or sentence after so many characters are exceeded.

    Be aware that if you toggle your WP Dashboard Settings from “Excerpt” to “Full Post” and use “Read More” tags to limit excerpt length, your RSS feed will show full posts in their entirety, as the RSS feed does not recognize “Read More” tags. This also has an implication for any email newsletter service providers or campaigns which you have automatically serving new blog content to subscribers via your RSS feed – subscribers will receive full posts via email, not posts with excerpts. This can limit traffic to your website and also leave you vulnerable to content “scraping”.

    I think your easiest option is to use the Advanced Excerpt plugin and change the excerpt length from the default 80 characters to something shorter that suits your purpose, like 30 characters. You can then define whether you want this to be a hard stop or whether you want to let the last word or sentence finish after the defined character limit is exceeded.

    If you opt to toggle your WP -> Settings -> Reading settings from “Excerpt” to “Full Post” to enable the more refined control of your excerpts / teasers via the use of custom “Read More” tags, the workaround for forcing your RSS feed to honor the “Read More” tag is outlined here and requires adding the below code to the functions.php file within your child Nisarg theme:

    /* 
    This function displays a custom teaser, by finding the teaser content using preg_split. It then appends a custom more link and returns the filtered content which then will show up in your RSS feed. 
    
    https://www.peterrknight.com/how-to-truncate-your-wordpress-rss-feed-at-the-more-tag/ 
    */ 
    
    function custom_rss_teaser( $content ){ 
    $teaser = preg_split( '/<span id\=\"(more\-\d+)"><\/span>/', $content ); 
    $readmore = '<p><a href="'.get_permalink().'">Continue Reading</a></p>'; 
    $content = $teaser[0].$readmore; 
    return $content; 
    } 
    add_filter( 'the_content_feed' ,'custom_rss_teaser' ); 

    Good luck!

    There is a plugin that allows you to do this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do I limit post excerpt length on homepage only?’ is closed to new replies.