get_theme_file_path()

WordPress 开发评论84阅读模式

get_theme_file_path()函数可以用来引入主题中某个文件,也就是说你想找到主题中某个文件,可以用此函数来查找。
语法

get_theme_file_path( string $file = '' )

$文件 (字符串) (可选) 要在样式表目录中搜索的文件。默认值: ”

返回值

文件的路径

实例1

require_once get_theme_file_path() .'/inc/functions.php';

加载主题inc目录functions.php文件

实例2

if ( file_exists( get_theme_file_path( '/inc/functions.php' ) ) ) {
	require get_template_directory() . '/inc/functions.php';
}

判断主题inc是否有functions.php文件,有则加载这个文件。

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
知更鸟
  • WordPress 开发
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证