wordpress原生文本截断函数

2014.05.04 2838 人浏览 留言
  1. <?php
  2.     $pc=$post->post_content;
  3.     $st=strip_tags(apply_filters('the_content',$pc));
  4.     if(has_excerpt())
  5.         the_excerpt();
  6.     elseif(preg_match('/<!--more.*?-->/',$pc) || mb_strwidth($st)<300)
  7.         the_content('Read more &raquo;');
  8.     elseif(function_exists('mb_strimwidth'))
  9.         echo wp_trim_words(strip_tags(apply_filters('the_content', $post->post_content)), $num_words = 100, $more = null);
  10.     else the_content();
  11. ?>

文章地址:https://huilang.me/isay/wordpress-yuan-sheng-wen-ben-jie-duan-han-shu/

回复本文

您的电子邮箱地址不会被公开。 必填项已用 * 标注

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif