/ Published in: PHP
Change the excerpt value in functions.php
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//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'); ?>