Npcink Blog
切换菜单

加载模板

加载指定模板,增强代码复用性

本页目录3 节

官方文档:

get_template_part

https://developer.WordPress.org/reference/functions/get_template_part/ 加载相关的模板,可提高主题代码的复用性。

举例:

一、
get_template_part( 'template-parts/content', 'none' );

加载指定目录下的 content-none.php 模板

二、

get_template_part( 'template-parts/content', get_post_type() );

不懂,望留言指教

get_post_type

https://developer.WordPress.org/reference/functions/get_post_type/