Revision: 25849
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 12, 2010 06:03 by howardpanton
Initial Code
//First add the filters functions
function wpe_excerptlength_teaser($length) {
return 45;
}
function wpe_excerptlength_index($length) {
return 30;
}
function wpe_excerptmore($more) {
return '...';
}
// Then the function
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 = '<p>'.$output.'</p>';
echo $output;
}
//The code for the template
<?php wpe_excerpt('wpe_excerptlength_index', 'wpe_excerptmore'); ?>
// the other one
<?php wpe_excerpt('wpe_excerptlength_teaser', 'wpe_excerptmore'); ?>
Initial URL
Initial Description
Change the excerpt value in functions.php
Initial Title
Custom wordpress excerpt lengths
Initial Tags
wordpress
Initial Language
PHP