WP酷 WP酷
  • 主题
  • 教程
  • 插件
  • 官方 QQ 群
  • 建站推荐
  • 联系
  • nicetheme® 奈思主题
  • 注册
    登录
立即登录
  • 请到 [后台->外观->菜单] 中设置菜单
首页 › WordPress 开发 › WordPress 4.1 中新的主题函数

WordPress 4.1 中新的主题函数

PCDotFan8年前

WordPress 4.1 中新的主题函数-WP酷WordPress 4.1 正式发布了,翻了下更新列表,新增不少非常实用的主题函数。让我来一个个介绍下吧。

 

add_theme_support( ‘title-tag’ )

在 WordPress 4.1 开始新增了一个名为 title-tag 的主题特性。 通过声明这个特性,主题就能知道自身并没有定义标题,WordPress 就可以安全的添加标题而无须担心会导致重复添加。

function theme_slug_setup() {
   add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'theme_slug_setup' );

 

 

the_archive_title() / get_the_archive_title()

WordPress 的归档种类有 N 多种,日期、分类、标签、文章形式等…… 而这个不起眼的函数却可以帮你节省不少归档模板上的逻辑处理。

the_archive_title( '<h1 class="page-title">', '</h1>' );

 

 

the_archive_description() / get_the_archive_description()

和上一个函数类似,这个函数会返回归档的相关描述。

the_archive_description( '<div class="taxonomy-description">', '</div>' );

 

 

the_post_navigation() / get_the_post_navigation()

返回当前文章的前/后导航。

while ( have_posts() ) : the_post();
	get_template_part( 'content', get_post_format() );
	the_post_navigation();
endwhile; // end of the loop.

 

the_posts_navigation() / get_the_posts_navigation()

 

返回文章列表的前/后导航。

if ( have_posts() ) :
	while ( have_posts() ) : the_post();
		get_template_part( 'content', get_post_format() );
	endwhile;
	the_posts_navigation();
else :
	get_template_part( 'content', 'none' );
endif;

 

 

the_posts_pagination() / get_the_posts_pagination()

返回文章列表的分页式导航。

if ( have_posts() ) :
	while ( have_posts() ) : the_post();
		get_template_part( 'content', get_post_format() );
	endwhile;
	the_posts_pagination();
else :
	get_template_part( 'content', 'none' );
endif;

 

参考资料

  • Exploring the Functions Added in WordPress 4.1
  • WordPress 4.1 Improvements for Theme Developers
  • 小影志
#WordPress#安全
0
分享

本站下载管理系统「dl.mywpku.com」因年久失修而永久关闭。若需获得往年主题,请至 WP酷的百度网盘(提取码: 5rbm) 自行搜索下载。默认解压密码为「www.mywpku.com」。

对您造成的不便,敬请谅解!

PCDotFan 站长
文章 435评论 859
相关文章
  • [6.0 更新中文汉化]极度流行的SEO插件 – WordPress SEO by Yoast
  • WordPress 新用户注册邮件链接提示「您的密码重设链接无效」
  • [Nginx] 搜索引擎不支持收录 https 网页以及 XP 系统不支持 SNI 的解决办法
  • [持续更新]Diaspora – 素色响应式单栏 WordPress 博客主题
  • WordPress 集成「有字库」字体服务
  • Jaguar – 单栏简约 WordPress 博客主题
  • [使用测评]Hostker / 主机壳 – 可能是最萌的云计算/虚拟主机服务商
  • [¥88]PCKr – 多功能响应式 WordPress 资讯主题
评论 (6)
再想想
  • 营销软件www.hyyingxiao.com

    路过看下

    8年前
  • 网上开店

    学习了

    8年前
  • QQ空间人气精灵

    这个不错

    8年前
  • 自动赚钱机

    学习了,不错支持

    8年前
  • 天天酷跑抽奖技巧

    WordPress图片主题 文

    8年前
  • 米赚破解版

    大家早上好

    8年前
PCDotFan
站长
若无特别注明,则默认我发布的所有文章均为内容原创 / 翻译原创,转载时请保留来源。
435文章
859评论
3K获赞
猜你喜欢
Puma – 单栏超简 WordPress 博客主题
7年前
多说提速:使用七牛云存储实现多说静态文件CDN
8年前
DW Question & Answer – 完善的WordPress在线问答插件
9年前
  • 杂记
  • WordPress 付费主题推荐
Copyright © 2023 WP酷. Designed by nicetheme. 琼ICP备13002067号-1