theme development - How to fix Wordpress images not showing up in local hosted XAMPP server?

I have recently been trying to establish a working method of developing Wordpress sites locally by making use of an XAMP

I have recently been trying to establish a working method of developing Wordpress sites locally by making use of an XAMPP server. The issue is that any images that I attempt to use refuse to show up when I load the page in a browser. I'm using the <?php echo get_template_directory(); ?>/library/images/name_of_the_svg_image file path, and when you right click and find them in the browser inspector HTML them shows the source as: C:\Program Files\xampp\htdocs\wp/wp-content/themes/**Site name**/library/images/name_of_the_svg_image Which, when I copy and paste it into the browser, shows the image properly. Is there something obvious that I am missing here?

I have recently been trying to establish a working method of developing Wordpress sites locally by making use of an XAMPP server. The issue is that any images that I attempt to use refuse to show up when I load the page in a browser. I'm using the <?php echo get_template_directory(); ?>/library/images/name_of_the_svg_image file path, and when you right click and find them in the browser inspector HTML them shows the source as: C:\Program Files\xampp\htdocs\wp/wp-content/themes/**Site name**/library/images/name_of_the_svg_image Which, when I copy and paste it into the browser, shows the image properly. Is there something obvious that I am missing here?

Share Improve this question edited Dec 11, 2019 at 22:24 RMcBTay asked Feb 2, 2015 at 2:18 RMcBTayRMcBTay 31 gold badge2 silver badges7 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

get_template_directory() Retrieves the absolute path to the directory of the current theme, without the trailing slash.

You should use get_template_directory_uri(); for showing correct image path on site.

echo get_template_directory();?>/library/images/name_of_the_svg_image will work in your case.

Details here

use bloginfo('template_url')

<?php echo bloginfo('template_url'); ?>/library/images/name_of_the_svg_image

you need a url... not directory...

more on bloginfo here

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744915217a4600792.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信