在开发wordpress主题模板制作的时候我们经常要获取当前模板的文件夹所在路径,现将使用的方法总结如下:
bloginfo(‘template_url’);
//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog
bloginfo(‘template_directory’);
//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog
echo get_template_directory_uri();
//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog
echo get_stylesheet_directory_uri();
//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog
echo get_template_directory();
//打印出 :\web\wordpress/wp-content/themes/xx-blog
echo home_url();
//打印:https://www.xxzhuit.com/wordpress
-> home_url()就是首页地址 比如logo的链接,“面包屑”的“首页”链接等等
//打印:https://www.xxzhuti.com/wordpress
site_url() 返回wordpress安装路径 如获得test.jpg图片文件绝对路径拼接:site_url().”/images/test.jpg”
欢迎关注我的公众号“xx主题网”,原创技术文章第一时间推送。
原文链接:https://blog.csdn.net/u011373875/article/details/125597754?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171852351316800227430046%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=171852351316800227430046&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-9-125597754-null-null.nonecase&utm_term=wordpress%E4%B8%BB%E9%A2%98