HOME 生活记录运维/编程
作者/来源:yixinu.com
栏目:运维/编程
日期:2013-03-31 23:40:07

进入到 wordpress 网站根目录

vim vim ./wp-includes/formatting.php  ,1894 行的  wp_trim_excerpt 函数


修改成 下面这样


function wp_trim_excerpt($text = '') {
  $raw_excerpt = $text;
  if ( '' == $text ) {
    $text = get_the_content('');
 
    $text = strip_shortcodes( $text );
 
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $excerpt_length = apply_filters('excerpt_length', 55); 
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    //$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    $text = mb_strimwidth( $text,0,"300", "............" );
  }
  return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}


那个300是显示的字数

分享到:

Copyright © 2013-2014 yixinu.com 湘ICP备14004402号

QQ:316686606  Email: 316686606@qq.com