最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论