您现在的位置是:首页 > 网站制作 > WordpressWordpress

WordPress函数get_template_part()

杰帅2023-08-19【Wordpress】人已围观

简介介绍

介绍

get_template_part( string $slug, string $name = null )

get_template_part()是用于调用主题目录中的文件。

参数

$slug
(string) (必填) The slug name for the generic template.

$name
(string) (选填) The name of the specialised template.

Default value: null

示例

调用主题中的 loop-index.php 文件。

<?php get_template_part( 'loop', 'index' ); ?>

调用子目录 partials 中的 content-page.php 文件。

<?php get_template_part( 'partials/content', 'page' ); ?>

调用不同的导航栏文件。

<?php get_template_part( 'nav' );           // Navigation bar (nav.php) ?>
<?php get_template_part( 'nav', '2' );      // Navigation bar #2 (nav-2.php) ?>
<?php get_template_part( 'nav', 'single' ); // Navigation bar to use in single pages (nav-single.php) ?>

Tags:wordpress主题   wordpress函数

很赞哦! ()

文章评论

本站推荐

站点信息

  • 建站时间:2018-10-24
  • 网站程序:帝国CMS7.5
  • 主题模板《今夕何夕》
  • 文章统计1172篇文章
  • 标签管理标签云
  • 统计数据百度统计
  • 微信公众号:扫描二维码,关注我们