本文介绍了WordPress的get_template_directory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,我期望它执行的操作是找到我正在使用的主题,并将该路径放置在/images/bg.png之前,到目前为止,我只得到了本地主机/ nameoffolder / images / bg.png但我想要的是localhost / nameoffolder / wp-content / themes / images / bg.png

I have the following code, what I am expecting it to do is locate the theme I am using and place that path before the /images/bg.png so far I just get the location which is localhost/nameoffolder/images/bg.png but what i want is localhost/nameoffolder/wp-content/themes/images/bg.png

<img src="<?php get_template_directory(); ?>/images/bg.png"></img>

这是我要显示的目录

推荐答案

我改用了这段代码,它起作用了

I used this code instead and it worked

<img src="<?php bloginfo( 'template_directory' ); ?>/images/bg.png"></img>

这篇关于WordPress的get_template_directory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 02:45