hehuiahui 发表于 2013-1-28 09:50:35

wordpress_Function Reference_get template part

在wordpress3.0以后的版本可以看到这样的代码
/* Run the loop for the archives page to output the posts. * If you want to overload this in a child theme then include a file * called loop-archive.php and that will be used instead. */ get_template_part( 'loop', 'archive' ); 如果你不明白可以参考: http://codex.wordpress.org/Function_Reference/get_template_part
下面是我笨拙的翻译
描述:
加载一个制定的模板到另一个模板里面(不同于包含header,sidebar,footer).
使得一个主题使用子模板来实现代码段重用变得简单
用于在模板中包含指定的模板文件,只需用指定参数slug和name就可以包含文件{slug}-{name}.php,最重要的功能是如果没有这个文件就包含没有{slug}的.php文件文件
使用方法:
<div class="syntaxhighlighterphp"><div class="line number1 index0 alt2">1
页: [1]
查看完整版本: wordpress_Function Reference_get template part