您现在的位置是:首页 > 网站制作 > 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
WordPress 页面模板(Page Template)下拉列表不显示的原因及解决方法
WordPress 的自定义页面模板是一个非常强大好用的功能,使用它新建一些静态页面(Page),添加上一些数据调用的函数,再在网页上做一个导航连接到对应的页面就可以实现很多自定义的功wp_reset_postdata 和 wp_reset_query 的作用与区别
什么时候使用wp_reset_query,什么时候用wp_reset_postdata?如何将WordPress文章迁移到Shopify:使用WP All Export插件的完整指南
如果您正在将WordPress网站迁移到Shopify,并希望将文章内容一起迁移,WP All Export插件是一个理想的解决方案。通过这款插件,您可以轻松导出WordPress中的文章,并将其转换为适合Shopify的CSV格式。