1fy07h 发表于 2024-10-6 12:50:01

wordpress获取当前主题文件夹所在的路径


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在<span style="color: black;">研发</span>wordpress主题模板制作的时候<span style="color: black;">咱们</span>经常要获取当前模板的文件夹所在路径,现将<span style="color: black;">运用</span>的<span style="color: black;">办法</span>总结如下:</span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">1、</span><span style="color: black;">办法</span>一</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">bloginfo(‘template_url’);</p>//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog

    <h1 style="color: black; text-align: left; margin-bottom: 10px;">二、<span style="color: black;">办法</span>二</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">bloginfo(‘template_directory’);</p>//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog

    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">3、</span><span style="color: black;">办法</span>三</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">echo get_template_directory_uri();</p>//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">4、</span><span style="color: black;">办法</span>四</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">echo get_stylesheet_directory_uri();</p>//打印出 :https://www.xxzhuti.com/wordpress/wp-content/themes/xx-blog
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">5、</span><span style="color: black;">办法</span>五:</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">echo get_template_directory();</p>//打印出 :\web\wordpress/wp-content/themes/xx-blog

    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">6、</span>额外添加:</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">echo home_url();</p>//打印:https://www.xxzhuit.com/wordpress
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">-&gt; home_url()<span style="color: black;">便是</span>首页<span style="color: black;">位置</span> <span style="color: black;">例如</span>logo的链接,“面包屑”的“首页”链接等等</span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">7、</span>echo site_url();</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">//打印:https://www.xxzhuti.com/wordpress</p>site_url() 返回wordpress安装路径 如<span style="color: black;">得到</span>test.jpg<span style="color: black;">照片</span>文件绝对路径拼接:site_url().”/images/test.jpg”




页: [1]
查看完整版本: wordpress获取当前主题文件夹所在的路径