I don’t really remember since how long I have had been using WordPress excerpts inside themes but I think almost all themes make use of the_excerpt() function. In relation to the excerpts, a theme developer needs certain functions like
- Custom length of excerpts
- Custom read more button
- Dynamic length of excerpts
Custom read more button#
To add a custom read more button you can add following function to your theme’s function.php
Custom length of excerpts#
Default length of WordPress excerpt is 55 words. You can use following funtion in functions.php to reduce it down to 15 or any custom value.
Dynamic length of excerpts#
What if you need dynamic excerpt length? I mean if you are building a complex WordPress theme, you find yourself in a condition where you need length of excerpts to be different for different pages or for different custom post types. I used to have a very lengthy function for this particular purpose whereas I discovered
wp_trim_words() a handy function to trim down the content to as many words as you want to with custom more symbol. Here is how I use it.
What do you use?#