wordpress获取当前主题文件夹的途径
发布时间:2022-06-22 11:02:12 所属栏目:教程 来源:互联网
导读:在wordpress主题模板制作的时候经常需要获取当前模板的文件夹服务器路径,因为经常忘的原因,所以在这里总结下几种方法,并且区分其之间的差别: (1)方法一: bloginfo(template_url); //打印出 :http://localhost/wordpress/wp-content/themes/simplespa
|
在wordpress主题模板制作的时候经常需要获取当前模板的文件夹服务器路径,因为经常忘的原因,所以在这里总结下几种方法,并且区分其之间的差别: (1)方法一: bloginfo('template_url'); //打印出 :http://localhost/wordpress/wp-content/themes/simplespace_free (2)方法二: bloginfo('template_directory'); //打印出 :http://localhost/wordpress/wp-content/themes/simplespace_free (3)方法三: echo get_template_directory_uri(); //打印出 :http://localhost/wordpress/wp-content/themes/simplespace_free (4)方法四: echo get_stylesheet_directory_uri(); //打印出 :http://localhost/wordpress/wp-content/themes/simplespace_free (5)方法五:(注意并非服务器路径,而是本机绝对路径) echo get_template_directory(); //打印出 :D:myWAPmyWebwordpress/wp-content/themes/simplespace_free (6)额外添加: echo home_url(); //打印:http://localhost/wordpress -> home_url()就是首页地址 比如logo的链接,“面包屑”的“首页”链接等等 echo site_url(); //打印:http://localhost/wordpress -> site_url() 返回wordpress安装路径 如获得test.jpg图片文件绝对路径拼接:site_url()."/images/test.jpg"。 (编辑:航空爱好网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐

