您现在的位置是:首页 > 网站制作 > 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函数
很赞哦! ()
相关文章
随机图文
WordPress 页面模板(Page Template)下拉列表不显示的原因及解决方法
WordPress 的自定义页面模板是一个非常强大好用的功能,使用它新建一些静态页面(Page),添加上一些数据调用的函数,再在网页上做一个导航连接到对应的页面就可以实现很多自定义的功wordpress 上传的图片不显示的问题 base64,data:image/gif
wordpress发布文章HTML标签被自动过滤掉该如何处理?
wordpress发布文章时很多html标签都会自动过滤掉,造成了文章中无法添加<style></style><script></script>等标签。那么该如何如何处理呢? 解决方法一: 将wp-includes文件夹下如何将WordPress文章迁移到Shopify:使用WP All Export插件的完整指南
如果您正在将WordPress网站迁移到Shopify,并希望将文章内容一起迁移,WP All Export插件是一个理想的解决方案。通过这款插件,您可以轻松导出WordPress中的文章,并将其转换为适合Shopify的CSV格式。
文章评论
本站推荐
标签云
猜你喜欢
- WordPress登陆用户和普通访客显示不同菜单设置图文教程
- WordPress获取相邻文章函数:get_adjacent_post
- WP Mail SMTP申请White Glove设置(我们为您设置SMTP)
- 目前市场上最流行的开源建站系统有哪些?
- wordpress调用当前页面下的子页面
- 通过XML网站地图验证器来排查WordPress网站错误
- 使用template_redirect为wordpress添加自定义页面
- 最快的WooCommerce主题(速度对比测试)
- wordpress建站优化技巧
- WordPress缩略图不显示“A TimThumb error has occured”“An error occured fetching image”解决方案