# 关于WordPress主题制作的常用函数解析

> 来源：梦飞idc云平台 | 原文：https://www.mfisp.com/2287.html | 发布：2021-11-26 | 更新：2021-11-26 | 分类：建站教程

![关于WordPress主题制作的常用函数解析](https://www.mfisp.com/wp-content/uploads/2021/10/2021102803401348.webp)

 

最近一直在学习使用WordPress制作主题，学习了很多常用函数，经常需要使用的原因，在这里记录下来。

 

## 头部常用函数

 

```
（1）site_url()：获取站点根链接

（2）wp_title()：获取文章或者静态页面标题

（3）bloginfo('name')：返回站点名称

（4）bloginfo('description')：返回站点描述

（5）get_stylesheet_directory()：样式文件所在目录

（6）bloginfo('stylesheet_url')：样式文件链接

（7）bloginfo('pingback_url')：pingback 链接

（8）bloginfo('template_url')：模板文件所在目录链接

（9）bloginfo('version')：WordPress 版本

（10）bloginfo('atom_url')：atom 链接

（11）bloginfo('rss2_url')：rss2 链接

（12）bloginfo('url')：网站根链接

（13）bloginfo('html_type')：html 版本

（14）bloginfo('charset')：字符集
```

 

## 判断函数

 

```
（1）is_home()：判断是否为首页

（2）is_paged()：判断是否为内容页(Page)

（3）is_single() ：是否为内容页(Post)

（4）is_category() ：是否为Category/Archive页

（5）is_tag() ：是否为Tag存档页

（6）is_date() ：是否为指定日期存档页

（7）is_year() ：是否为指定年份存档页

（8）is_month() ：是否为指定月份存档页

（9）is_day() ：是否为指定日存档页

（10）is_time() ：是否为指定时间存档页

（11）is_archive() ：是否为存档页

（12）is_search()：是否为搜索结果页

（13）is_404() : 是否为 “HTTP 404: Not Found” 错误页

（14）is_paged() : 主页/Category/Archive页是否以多页显示

是否的返回ture或false
```

 

## 模板函数

 

```
1、the_title()：文章标题
2、the_content()：文章内容
3、the_title()：文章标题
4、the_permalink()：文章链接
5、the_category()：文章分类
6、the_author()：文章作者
7、the_ID()：文章 ID
8、the_time(‘Y-m-d’)：显示时间，格式为：’年-月-日′
8、next_post_link('%link')：下一篇文章链接
9、previous_post_list('%link')：上一篇文章链接
```

 

上面这些函数也只是满足基本使用，想要制作一个完善的WordPress主题还需要学习更多的函数和php知识。

 

后续小编还会更新一些在制作WP主题遇到的问题和函数解析的文章

---
本页由 梦飞idc云平台（https://www.mfisp.com）提供。站点导航见 https://www.mfisp.com/llms.txt
