Wordpress摘录长度标记
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress摘录长度标记相关的知识,希望对你有一定的参考价值。
function that creates a template tag that can be used to insert excerpts with different lengths. Also controls characters that come after excerpt
// In Functions.php: function the_excerpt_max_charlength($charlength) { $excerpt = get_the_excerpt(); $charlength++; if(strlen($excerpt)>$charlength) { $subex = substr($excerpt,0,$charlength-5); $exwords = explode(" ",$subex); $excut = -(strlen($exwords[count($exwords)-1])); if($excut<0) { echo substr($subex,0,$excut); } else { echo $subex; } echo "[...]"; } else { echo $excerpt; } } // In wordpress template: <?php the_excerpt_max_charlength(250); ?>
以上是关于Wordpress摘录长度标记的主要内容,如果未能解决你的问题,请参考以下文章