举例:获取主题目录下的文件,比如图片文件
<?php
$dir = get_template_directory_uri();
?>
<a class="item"><img src="<?php echo $dir . '/assets/owl2/img/fullimage1.jpg'; ?>" alt=""></a>
url(<?php echo get_template_directory_uri(); ?>/assets/images/banner02.jpg)
背景图片
<?php
$dir = get_template_directory_uri();
?>
<li role="complementary" id="banner-li" style="background-image: url(<?php echo $dir . '/assets/images/banner01.jpg'; ?>)">
//或者
<li role="complementary" id="banner-li" style="background-image: url(<?php echo get_template_directory_uri(); ?>/assets/images/banner02.jpg)">
举例:
if ( 'posts' == get_option( 'show_on_front' ) ) {
include( get_home_template() );
}
原文:get_home_template
Retrieve path of home template in current or parent template.
获取首页模板的路径
返回:首页模板文件的全路径,比如:
get_home_template():得到的路径如下(如果没有有home.php,会获取index.php。)
E:\phpStudy\PHPTutorial\WWW\bootstrap4wp/wp-content/themes/wp-bootstrap-4-pro-child-theme/home.php
1
其他
get_front_page_template()
get_index_template()
get_page_template()
E:\phpStudy\PHPTutorial\WWW\bootstrap4wp/wp-content/themes/wp-bootstrap-4-pro-child-theme/front-page.php
E:\phpStudy\PHPTutorial\WWW\bootstrap4wp/wp-content/themes/wp-bootstrap-4-pro-child-theme/index.php
E:\phpStudy\PHPTutorial\WWW\bootstrap4wp/wp-content/themes/wp-bootstrap-4-pro-child-theme/page.php
使用:
include( get_home_template() );
1
来源:
wp-includes/template.php
其他类似函数:
get_privacy_policy_template()
get_embed_template()
get_singular_template()
get_search_template()
get_single_template()
get_attachment_template()
get_date_template()
get_home_template()
get_query_template()
get_front_page_template()
get_index_template()
get_page_template()
get_404_template()
get_archive_template()
get_post_type_archive_template()
get_author_template()
get_category_template()
get_tag_template()
get_taxonomy_template()