WordPress主题开发:截取标题或内容
2017-02-02 22:08
260 查看
截取可以用wp_trim_words()
用法:
参数说明:$text---截取内容,$num_words ---限定字数,$more ---截取后加在尾部的字符
截取文章内容:
截取文章标题:
用法:
<?php $trimmed = wp_trim_words( $text, $num_words = 55, $more = null ); ?>
参数说明:$text---截取内容,$num_words ---限定字数,$more ---截取后加在尾部的字符
截取文章内容:
<?php $content = get_the_content(); $trimmed_content = wp_trim_words( $content, 40, '<a href="'. get_permalink() .'"> ...Read More</a>' ); echo $trimmed_content; ?>
截取文章标题:
<?php $title = get_the_title(); $trimmed_title = wp_trim_words( $title, 20, '...' ); echo $trimmed_title; ?>
相关文章推荐
- asp.net开发网站时指定或截取标题字数的方法和内容页多关键字切分的方法
- WordPress主题开发:通过page的ID或者别名获取内容
- WordPress主题开发实例:格式化标题
- wordpress主题开发教程手记:wp-login.php登录页面优化
- wordpress主题开发教程手记:自定义系统默认发信人
- WordPress主题开发
- WordPress官方主题开发文档
- 我要用wordpress做一个企业站的主题,并且我真的很想整个的开发过程是我自己的亲历亲为~~~~
- 帝国cms列表页模板中标题的截取与内容的截取
- wordpress主题开发教程手记:启用主题后自动创建页面
- Android开发指南-框架主题-内容提供器
- WordPress 主题开发 - (二) 理解主题 待翻译
- ASP.NET中怎样截取文章标题或者内容的一部分进行显示
- wordpress主题开发常用缓存API的讲解与调用方案
- iOS开发 关于照片截取内容旋转的问题
- wordpress主题开发教程手记:自定网站登出链接
- Android开发指南-框架主题-内容提供器
- wordpress截取标题字符最简单的方法
- Asp.net网站开发备忘笔记(1)----设置关键字/内容描述/标题