站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Include Tags
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
Fludlen
(
讨论
|
贡献
)
2008年7月11日 (五) 17:31的版本
(
差异
)
←上一版本
|
最后版本
(
差异
) |
下一版本→
(
差异
)
跳转至:
导航
、
搜索
警告:您正在编辑的是本页面的旧版本。
如果您发布该更改,该版本后的所有更改都会丢失。
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
The Template '''include tags''' are used within one [[WordPress:Templates|Template]] file (for example <tt>index.php</tt>) to execute the [[WordPress:Glossary#HTML|HTML]] and [[WordPress:Glossary#PHP|PHP]] found in another template file (for example <tt>header.php</tt>). [http://www.php.net PHP] has a built in [http://us3.php.net/manual/en/function.include.php include()] statement for this purpose, but these WordPress template tags make including certain specific files much easier. 模板'''include tags'''是用在[[WordPress:Templates|模板]] 文件内(例如<tt>index.php</tt>)以执行其它模板文件内的[[WordPress:Glossary#HTML|HTML]] 和[[WordPress:Glossary#PHP|PHP]] (例如<tt>header.php</tt>)。[http://www.php.net PHP]有一个内置的[http://us3.php.net/manual/en/function.include.php include()]声明,但是这些WordPress模板标签使得包含某些特别的文件变得更加简单。 See [[WordPress:Using Themes]] and [[WordPress:Theme Development]] for more information about Templates and Themes. 关于模板和主题的更多的信息,请看看[[WordPress:Using Themes|使用主题]] 和[[WordPress:Theme Development|主题发展]]。 == The Header Template == == 标题模板 == <?php get_header(); ?> <?php get_header(); ?> This tag includes the file <tt>header.php</tt> from your current theme's directory. If that file is not found, it will instead include <tt>wp-content/themes/default/header.php</tt>. 这个标签包含来自当前主题目录的文件<tt>header.php</tt>。如果没有发现这个文件,标签会包含<tt>wp-content/themes/default/header.php</tt>。 == The Footer Template == == 页底文字模板 == <?php get_footer(); ?> <?php get_footer(); ?> This tag includes the file <tt>footer.php</tt> from your current theme's directory. If that file is not found, it will instead include <tt>wp-content/themes/default/footer.php</tt>. 这个标签包含来自当前主题目录的文件<tt>footer.php</tt>。如果没有发现这个文件,标签会包含<tt>wp-content/themes/default/footer.php</tt>。 == The Sidebar Template == == 工具条模板 == <?php get_sidebar(); ?> <?php get_sidebar(); ?> This tag includes the file <tt>sidebar.php</tt> from your current theme's directory. If that file is not found, it will instead include <tt>wp-content/themes/default/sidebar.php</tt>. 这个标签包含当前主题目录的文件<tt>sidebar.php</tt>。如果没有发现这个文件,标签就会包含<tt>wp-content/themes/default/sidebar.php</tt>。 <?php get_sidebar('right'); ?> <?php get_sidebar('right'); ?> Causes the template <code>TEMPLATEPATH . 'sidebar-right.php'</code> to be included. Note: the ability to specify a particular sidebar, meaning more than one sidebar template can be used in a theme, was added with [[WordPress:Version 2.5]]. 导致模板<code>TEMPLATEPATH . 'sidebar-right.php'</code>被包含其中。注:能够规定一个特别的工具条,指的是一个主题中可以使用多个工具条模板,是在[[WordPress:Version 2.5|2.5版本]]中添加的。 == The Comments Template == == 评论模板 == <?php comments_template(); ?> <?php comments_template(); ?> This tag includes the file <tt>comments.php</tt> from your current theme's directory. If that file is not found, it will instead include <tt>wp-content/themes/default/comments.php</tt>. To display comments on the main index or archive pages, you'll need to set the <tt>$withcomments</tt> variable to <tt>"1"</tt> before calling this tag. 这个标签包含来自当前主题目录的文件<tt>comments.php</tt>。如果没有发现这个文件,主题会包含<tt>wp-content/themes/default/comments.php</tt>。要在主索引或者归档网页上显示评论,你需要将<tt>$withcomments</tt>变数设置为<tt>"1"</tt>,才能够访问这个标签。 == Including Any Template == == 包含任何模板 == WordPress offers the above tags for including those specific [[WordPress:Templates]], but there is also a convenient way to include ''any'' file. To do so, you will need to use the <tt>[http://us2.php.net/manual/en/function.include.php include]</tt> [[WordPress:Glossary#PHP|PHP]] function, and a constant WordPress conveniently defines for you to make things easy: <tt>TEMPLATEPATH</tt>. WordPress提供了上述标签,用来包含这些特别的[[WordPress:Templates|模板]],但是还有一个更简便的方法,能够包含''任何''文件。要使用这种方法,你需要使用<tt>[http://us2.php.net/manual/en/function.include.php include]</tt> [[WordPress:Glossary#PHP|PHP]]函数,和一个WordPress能够方便地为你定义的一个恒量,使得问题变得更加简单:<tt>TEMPLATEPATH</tt>。 Suppose you want to include a file called <tt>header2.php</tt>. Just insert the following line in your template where you want that file's information to appear. 假如你想要包含一个称为<tt>header2.php</tt>的文件。只要将下面的这些行插入到模板中,你想要文件信息显示的位置中。 <?php include (TEMPLATEPATH . '/header2.php'); ?> <?php include (TEMPLATEPATH . '/header2.php'); ?> You could, for example, use this as a means of including a different header instead of the normal <tt>header.php</tt> which would be included with <tt>[[WordPress:#The Header Template|get_header()]]</tt>. 例如,你可以使用这个作为包含一个不同的标题而不是正常的<tt>header.php</tt>的方式,<tt>header.php</tt>可能包含在<tt>[[WordPress:#The Header Template|get_header()]]</tt>。 '''NOTE''': <tt>TEMPLATEPATH</tt> is a reference to the absolute path to the current theme directory (without the / at the end). For information on referencing URIs rather than including files, see [[WordPress:Theme Development#Referencing Files From a Template|Referencing Files From a Template]]. '''注''': <tt>TEMPLATEPATH</tt>是一个到达当前主题目录的绝对路径的一个reference(结尾没有/)。关于referencing URI而不是包含文件的信息,请看看[[WordPress:Theme Development#Referencing Files From a Template|从一个模板中Referencing 文件]]。 == Example == == 例子 == The following is a ''very'' simple example of a template for an "HTTP 404: Not Found" error (which you could include in your [[WordPress:Theme Development|Theme]] as <tt>404.php</tt>). 下面是有关"HTTP 404:没有找到"错误模板的一个''非常''简单的例子(可能包含在你的[[WordPress:Theme Development|主题]]中作为<tt>404.php</tt>)。 <?php get_header(); ?> <h2>Error 404 - Not Found</h2> <?php get_sidebar(); ?> <?php get_footer(); ?> <?php get_header(); ?> <h2>Error 404 - Not Found</h2> <?php get_sidebar(); ?> <?php get_footer(); ?> == Parameters == == 参数 == These tags do not accept any parameters. 这些标签不接受任何参数。 <!-- == Related == {{Tag General Tags}} {{No Param Tag Footer}} --> {{No Param Tag Footer}} <!-- == 相关的 == {{标签 总 标签}} {{没有Param 标签 页底文字}} --> {{没有 Param标签 页底文字}}
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)