很多wordpress主题首页默认调用网站全文,或者首页文章摘要只显示55个字,很多朋友不知怎么修改。
今天给大家介绍一下wordpress首页显示摘要及修改摘要字数的方法
我们需要用到如下代码:
<?php echo mb_strimwidth(strip_tags(get_the_content()),0,200," ");/*the_excerpt();the_content(__('Read more...', 'inove'));*/ ?><a rel="more-link" href="<?php%20the_permalink()?>" title="<?php the_title(); ?>">……查看详情</a>
使用方法如下:
1、将该代码替换原来的文章代码:
<?php the_content(); ?>
或者原来的摘要代码:
<?php the_excerpt("Read More..."); ?>
2、修改代码中的数字200为你想要显示摘要的字数即可。
function new_excerpt_length($length)
{
return 200;
}
这个就行
这个不行呢 5.0.2版本
哦哦,这个文章很早了,是2013年的,应该是wp版本升级之后,以前的一些代码都改变了