get_template_part() 函数用于调用自定义模板文件,有点像php中的include,加载其他页面,或者说是html里面的iframe标签,能把一个页面加载进当前页面!

函数用法:

<?php get_template_part( $slug, $name ); ?>

$slug-要引入的模板的文件名 $name -要引入的模板的文件的副文件名

例如:如果content-loop.php存在,则调用content-loop.php,否则,就调用content.php
<?php get_template_part( 'content', 'loop' ); ?>
例如:引入当前主题 inc 目录的 myfunctions.php 文件:
<?php get_template_part( 'inc/myfunctions' ); ?>
例如:引入当前主题根目录的 tags.php文件:
<?php get_template_part( 'tags' );  ?>