Writing custom excerpts for posts can be a pain, so why not just change how long they're supposed to be? This is how:
Changing The Default WordPress Excerpt Length
No plugin required!
Printable View
Writing custom excerpts for posts can be a pain, so why not just change how long they're supposed to be? This is how:
Changing The Default WordPress Excerpt Length
No plugin required!
I used to use a plugin, but now I will give this a shot.
Thanks :)
I would not recommend this!
You will have to do this every time you update your WP installation. It is better to write a custom function in your functions.php
and then you call it like this:PHP Code:function limit_content($ctolimit, $clen = 280)
{
$cut = substr(strip_tags($ctolimit), 0, $clen);
$sensible_cut_position = strrpos($cut, ' ');
return substr($cut, 0, $sensible_cut_position);
}
$ctolimit - text to limit (can be get_the_content();)PHP Code:<?php echo limit_content($ctolimit,$clen);?>
$clean - number of characters to limit, default value is 280, but can be set to whatever you like. The $clean parameter is optional.
The function returns only text without tags.
This simple function does not break words, and the number of characters is more like a maximum for string length. This function searches for the last occurrence of a space (assumed word end ) at the end of the given text, and returns the cropped text.
Question: why use PHP "hacks" when you can use manual excerpts? Excerpt « WordPress Codex