wordpress原生文本截断函数
- <?php
- $pc=$post->post_content;
- $st=strip_tags(apply_filters('the_content',$pc));
- if(has_excerpt())
- the_excerpt();
- elseif(preg_match('/<!--more.*?-->/',$pc) || mb_strwidth($st)<300)
- the_content('Read more »');
- elseif(function_exists('mb_strimwidth'))
- echo wp_trim_words(strip_tags(apply_filters('the_content', $post->post_content)), $num_words = 100, $more = null);
- else the_content();
- ?>
发布于记忆碎片-网络技术分享 https://huilang.me
文章地址:https://huilang.me/isay/wordpress-yuan-sheng-wen-ben-jie-duan-han-shu/