Because it states within the title, I am searching for multiple excerpt measures in WordPress.
I realize this can be done in functions.php:
function twentyten_excerpt_length( $length ) add_filter( 'excerpt_length', 'twentyten_excerpt_length' )
What I wish to know is the best way to have multiple of those each coming back different statistical values in order to get short excerpts for sidebar loops, longer excerpts for featured loops, and also the longest excerpt for that primary article.
Something similar to with such within the templates:
<?php the_excerpt('length-short') ?> <?php the_excerpt('length-medium') ?> <?php the_excerpt('length-long') ?>
function excerpt($limit) else $excerpt = preg_replace('`[[^]]*]`','',$excerpt) return $excerpt function content($limit) else $content = preg_replace('/[.+]/','', $content) $content = apply_filters('the_content', $content) $content = str_replace(']]>', ']]&gt', $content) return $content
then inside your template code you simply use..
<?php echo excerpt(25) ?>
This is exactly what I emerged with.
Add this for your
class Excerpt Wordpress filter * And instantly calls the_excerpt() * * @param string $new_length * @return void * @author Baylor Rae' */ public static function length($new_length = 55) // Informs Wordpress the brand new length public static function new_length() // Echoes the excerpt public static function output() // An alias towards the class function my_excerpt($length = 55)
You can use it such as this.
my_excerpt('short') // calls the defined short excerpt length my_excerpt(40) // 40 chars
This is actually the simplest method in which I understand of to include filters, which are callable in one function.
I discovered an excellent wordpress plugin that may do that -- Content and Excerpt Word Limit