php wordpress自定义中的多个摘录长度
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php wordpress自定义中的多个摘录长度相关的知识,希望对你有一定的参考价值。
<?php
function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
return $excerpt;
}
function content($limit) {
$content = explode(' ', get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(" ",$content).'...';
} else {
$content = implode(" ",$content);
}
$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]
>
', ']]>', $content);
return $content;
}
<?= excerpt(25); ?>
以上是关于php wordpress自定义中的多个摘录长度的主要内容,如果未能解决你的问题,请参考以下文章
PHP 显示具有自定义摘录长度的帖子和自定义在WordPress中阅读更多文本
PHP wordpress中的多个摘录长度
自定义wordpress摘录长度
wordpress中的多个摘录长度
在WordPress中显示具有自定义摘录长度和自定义阅读更多文本的文章
Wordpress摘录自定义字数限制