wordpress模板怎么用,wordpress模板包含标签使用介绍
wordpress模板包含标签指的是在一个模板文件中包含另一个模板文件时涉及到的其它标签,在php中使用包含文件的函数是
include
include_once
require
require_once
而在wordpress模板中包含另外一个模板使用了以下函数:
get_header()
get_footer()
get_sidebar()
get_template_part()
get_search_form()
comments_template()
1、 get_header():包含头部模板用法:
说明:get_header() 标签包含了当前使用主题的头部模板文件: header.php 或者 header-{name}.php ,如果没有该文件则使用系统默认的头部模板文件: wp-includes/theme-compat/header.php 。
2、 get_footer():包含底部模板用法:
说明:get_footer() 标签包含了当前使用主题的底部模板文件:footer.php 或者 footer-{name}.php ,如果没有该文件则使用系统默认的底部模板文件: wp-includes/theme-compat/footer.php.3、get_sidebar():包含侧边栏模板用法:
说明:get_sidebar() 标签包含了当前使用主题的侧边栏模板文件:sidebar.php 或者 sidebar-{name}.php, 如果没有该文件则使用系统默认的侧边栏模板文件:wp-includes/theme-compat/sidebar.php。4、 get_template_part():包含自定义模板用法:
说明:get_template_part() 标签包含了当前使用主题的自定义的模板文件: {slug}.php 或者 {slug}-{name}.php。
5、 get_search_form():包含搜索框模板用法:
说明:get_search_form() 标签包含了当前使用主题的搜索框的模板文件: searchform.php ,如果没有该文件则使用系统生存默认的搜索框。
6、 comments_template():包含评论模板用法:
comments_template() 标签包含了当前使用主题的评论的模板文件 comments.php, 如果没有该文件则使用系统默认的评论模板文件: wp-includes/theme-compat/comments.php。
标签应用实例
以下代码是一个简单的404页面模板实例,模板页面显示 “HTTP 404: Not Found”,主题中你可以将该文件命名为404.php。
模板参数
get_header(), get_footer() 和 get_sidebar() 接收以下的一个参数:
$name(string) (可选) 调用 sidebar-{name}.php 格式的模板文件。 例如: sidebar-right.php, header-single.php 或者 footer-8.php.默认: None
get_template_part() 接收以下两个参数:
$slug(string) (必须) 调用 {slug}.php格式的模板文件。例如: nav.php默认: None$name(string) (可选) 调用 {slug}-{name}.php格式模板文件。例如: nav-home.phpDefault: None
本文地址:IT问答频道 https://www.eeeoo.cn/itwenda/918245.html,嗨游网一个专业手游免费下载攻略知识分享平台,本站部分内容来自网络分享,不对内容负责,如有涉及到您的权益,请联系我们删除,谢谢!