WordPress主题开发:截取标题或内容
截取可以用wp_trim_words()
用法:
<?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;
?>
WordPress主题开发:截取标题或内容的更多相关文章
- 黄聪:《跟黄聪学WordPress主题开发》
又一个作品完成!<跟黄聪学Wordpress主题开发>,国内最好的Wordpress主题模版开发视频教程!! 目录预览: WordPress官方源文件层式结构讲解 WordPress数据库 ...
- wordpress 主题开发
https://yusi123.com/3205.html https://themeshaper.com/2012/10/22/the-themeshaper-wordpress-theme-tut ...
- WordPress 主题开发:从入门到精通(必读)
本专栏介绍如何开发设计你自己的 WordPress 主题.如果你希望了解更多如何安装和应用主题的内容,请参阅应用主题文档.本文的内容不同于应用主题,因为所讨论的是编写代码去构建你自己的主题的技术内容, ...
- WordPress 主题开发 - (三) 开发工具 待翻译
Before we get started building any WordPress Theme, we’re going to need to get our development tools ...
- WordPress 主题开发 - (一) 前言 待翻译
原文出自: http://themeshaper.com/2012/10/22/the-themeshaper-wordpress-theme-tutorial-2nd-edition/ THE TH ...
- [转]WordPress主题开发:主题初始化
本文转自:http://www.cnblogs.com/tinyphp/p/4391182.html 在最简单的情况下,一个WordPress主题由两个文件构成: index.php -------- ...
- WordPress主题开发:style.css主题信息标记
在最简单的情况下,一个WordPress主题由两个文件构成: index.php ------------------主模版 style.css -------------------主样式表 而且s ...
- WordPress主题开发:主题初始化
在最简单的情况下,一个WordPress主题由两个文件构成: index.php ------------------主模版 style.css -------------------主样式表(注意 ...
- WordPress主题开发:通过page的ID或者别名获取内容
访问地址:xx/?page_id=12 如果是在当前页面,只需要通过循环就可以输出对应的信息 <?php if(have_posts()):while(have_posts()):the_pos ...
随机推荐
- .NetCore源码阅读笔记系列之Security (一) Authentication & AddCookie
如果你使用过.NetCore开发过程序,你会很清楚,在其中我们经常会用到一些如下的代码 services.AddAuthentication(options => { options.Defau ...
- hdu 2545 求当前结点到根节点的距离
求当前结点到根节点的距离 Sample Input 2 1 //n m 1 2 1 2 //询问 5 2 1 2 1 3 3 4 3 5 4 2 //询问 4 5 0 0 Sample Output ...
- 【BZOJ】1294: [SCOI2009]围豆豆Bean
题解 随机跳题真好玩 这个就是考虑我们怎么判断点在多边形内,就是点做一条射线,穿过了奇数条边 我们只需要记录一个二进制状态表示每个点的射线穿过路径的次数的奇偶性 枚举起点,然后用BFS的方式更新dp状 ...
- ref:Spring JdbcTemplate+JdbcDaoSupport实例
ref:https://www.yiibai.com/spring/spring-jdbctemplate-jdbcdaosupport-examples.html 在Spring JDBC开发中,可 ...
- MyBatis Plus + Activiti 整合报错:org.springframework.beans.factory.UnsatisfiedDependencyException
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ind ...
- SpringBoot详细研究-05微服务与拾遗
这将是SpringBoot学习系列的最后一篇文章,主要涉及Spring Cloud和JHispter两个知识点,都具有一定综合性,需要多加实践加强理解. Spring Cloud 微服务Microse ...
- Chart.js Y轴数据以百分比展示
新手一枚,解决的问题喜欢记录,也许正好有人在网上迷茫的百度着.-0- 最近使用Chart.js做折线图的报表展示,直接显示整数啥的很好弄毕竟例子直接在哪里可以用,百分比就没办法了.百度慢慢汲取营养,虽 ...
- openQPA[01]初次认识与使用
开源项目QPA 1.项目主页:[http://protocol.sinaapp.com/] 2.项目介绍: 3.运行项目: (1)安装python2.7,并安装PyQt4. 下载地址[https: ...
- 【BZOJ 3027】 3027: [Ceoi2004]Sweet (容斥原理+组合计数)
3027: [Ceoi2004]Sweet Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 71 Solved: 34 Description John ...
- Bzoj2149拆迁队:cdq分治 凸包
国际惯例的题面:我们考虑大力DP.首先重新定义代价为:1e13*选择数量-(总高度+总补偿).这样我们只需要一个long long就能维护.然后重新定义高度为heighti - i,这样我们能选择高度 ...