您现在的位置是:首页 > 网站制作 > 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 上传的图片不显示的问题 base64,data:image/gif
-
wp_reset_postdata 和 wp_reset_query 的作用与区别
什么时候使用wp_reset_query,什么时候用wp_reset_postdata? -
wordpress发布文章HTML标签被自动过滤掉该如何处理?
wordpress发布文章时很多html标签都会自动过滤掉,造成了文章中无法添加<style></style><script></script>等标签。那么该如何如何处理呢? 解决方法一: 将wp-includes文件夹下 -
WordPress 页面模板(Page Template)下拉列表不显示的原因及解决方法
WordPress 的自定义页面模板是一个非常强大好用的功能,使用它新建一些静态页面(Page),添加上一些数据调用的函数,再在网页上做一个导航连接到对应的页面就可以实现很多自定义的功
文章评论
本站推荐
标签云
猜你喜欢
- Google SEO之如何优化内容 - Google SEO指南 03
- 谷歌推广如何收费?谷歌推广费用分析(详细解答)
- 致命错误Call to undefined function“wp_filesize” in /wp-admin/includes/image.php:249解决办法 - 搬主题
- WordPress函数the_author_link()
- 2023年度优秀WordPress博客主题推荐
- WordPress调用最新文章 热门文章 相关文章 随机文章代码
- WordPress网站如何禁止修改后台模板文件
- 在Apache/Nginx反向代理上设置WP Hide Pro教程
- WordPress 6.1 “Misha” 正式发布
- WordPress建站用哪个主机好?WordPress主机评测推荐