文章摘要代码:
摘要调用:
<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 200,"……");?>
其中200是调用的字符 为100个字
WordPress首页显示文章的摘要有什么插件啊?
插件名称: wp-utf8-excerpt
主要特点: 1,支持多字节语言(如中文),不会产生乱码。 2,摘要可保留文章中的格式标签,如字体、颜色、链接、图片等(需保留的标签可在后台设置)。 3,首页每篇文章显示300字,存档页面每篇文章显示150字(字数可设置)。
wordpress首页文章只显示标题和摘要的方法?
首先,到wordpress后台,依次选择 外观-->编辑-->选择右边的index.php文件,在里面可以看到语句
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
其次可以看出,index.php是嵌套一个 content.php 的文件用于专门显示文章的内容,这就是为什么在首页老是显示文章全文。那么,打开content.php文件找到
<?php
the_content( __( 'Continue reading <span>→</span>', 'twentyeleven' ) );
?>
将它修改为
<?php if(!is_single()) {
the_excerpt();
} else {
the_content(__('(more…)'));
} ?>
最后,保存,就显示摘要了。
wordpress 文章摘要 长度如何设置
在functions.php中添加以下代码:
/***自定义内容显示长度
*@paramnumber$len长度,默认60字节
*@paramstring$flag是否显示摘要标志,默认显示
*/
functionfly_custom_content_length($len=60,$flag=true){
$text='';
$content=get_the_content();
$content=apply_filters('the_content',$content);
$content=str_replace(']]>',']]>',$content);
$content=strip_shortcodes($content);
$content=strip_tags($content);
if(!has_excerpt($post->ID)){
if(strlen($content)>$len)$text=mb_substr($content,0,$len).'…';
}else{
$text=get_the_excerpt();
if($flag){
if(strlen($text)>$len)$text=mb_substr($text,0,$len);
}else{
if(strlen($content)>$len)$text=mb_substr($content,0,$len).'…';
}
}
echo$text;
}
注意函数名不要和已有的冲突
wordpress最近文章分类中如何显示文章摘要
添加相关的函数,具体什么函数不记得了,你可以百度下,另外,也不建议在侧栏显示摘要,太那个了,麻烦....
参考资料:WordPress啦!聚合全球资源,助力中文WordPress。
WordPress如何让一篇文章摘要固定显示在首页
使用WP-Sticky插件
怎么改变wordpress文章摘要字数
方法有很多。
修改文件法
找到WorsPress目录wp-includes下formating.php文件,查找unction wp_trim_excerpt($text)函数,再找到excerpt_length,默认值是55,修改成需要的值即可。
修改function.php法
functioncustom_excerpt_length($length){return200;
}
add_filter('excerpt_length','custom_excerpt_length',999);
200为字数,可以修改为自己的值。
还有就强大的插件。
WP CN Excerpt插件不错。
如何在wordpress的首页中只显示文章的摘要
你在主题中新建2个customfield,用于在后台编辑页面输入文章来源和文章来源的链接,然后在前台的文章列表页面调用这2个postmeta,用html以合适的方式输出即可获得你想要的效果。自定义customfield的开源类在GITHUB有,自己搜一下
转载请注明出处51数据库 » wordpress文章摘要 wordpress文章摘要怎么写
內氵函段子