Well, this will come in really handy for the future you need wordpress 2.9, for this to work
Quite often I would like different excerpt lengths in different places on themes, so now it is possible
function wpe_excerptlength_teaser($length) {
return 55;
}
function wpe_excerptlength_cat($length) {
return 35;
}
function wpe_excerptmore($more) {
return '...';
}
function wpe_excerpt($length_callback='', $more_callback='') {
global $post;
if(function_exists($length_callback)){
add_filter('excerpt_length', $length_callback);
}
if(function_exists($more_callback)){
add_filter('excerpt_more', $more_callback);
}
$output = get_the_excerpt();
$output = apply_filters('wptexturize', $output);
$output = apply_filters('convert_chars', $output);
$output = ''.$output.'
';
echo $output;
}
replace your the_excerpt()
accordingly
<?php wpe_excerpt('wpe_excerptlength_teaser', 'wpe_excerptmore'); ?>
<?php wpe_excerpt('wpe_excerptlength_cat', 'wpe_excerptmore'); ?>
Original code from WPengineer Chapeau!





Recent discussions