Heim  >  Artikel  >  Backend-Entwicklung  >  WordPress主题制作之模板文件的引入方法,wordpress模板_PHP教程

WordPress主题制作之模板文件的引入方法,wordpress模板_PHP教程

WBOY
WBOYOriginal
2016-07-12 09:02:20826Durchsuche

WordPress主题制作之模板文件的引入方法,wordpress模板

get_template_part() 用来引用模板文件,类似于 get_header()、get_sidebar() 和 get_footer(),只不过这个 get_template_part() 可以引入自定义名字的文件。

使用方法

get_template_part( $slug, $name );

参数

$slug

(字符串)(必须)要引入的模板的文件名,不包括后缀名 .php,也就是如果需要引入当前主题根目录的 loop.php 文件 $slug 填写 “loop” 即可。

默认:None

$name

(字符串)(可选)要引入的模板的文件的副文件名,如果要引入当前主题根目录的 loop-img.php 文件 $slug 参数填写 “loop”,$name 参数填写 “img”。

默认值:None

返回值

此函数无返回值。

例子

引入当前主题根目录的 endskin.com 文件:

get_template_part( 'endskin' );

引入当前主题 part 目录的 loop.php 文件:

get_template_part( 'part/loop' );

引入当前主题根目录的 endskin-com.php 文件:

get_template_part( 'endskin', 'com' );

其它

此函数位于:wp-includes/general-template.php

您可能感兴趣的文章:

  • WordPress的主题编写中获取头部模板和底部模板
  • 讲解WordPress中用于获取评论模板和搜索表单的PHP函数

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1085875.htmlTechArticleWordPress主题制作之模板文件的引入方法,wordpress模板 get_template_part() 用来引用模板文件,类似于 get_header()、get_sidebar() 和 get_footer(),只不过...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn