Php 如何通过本地链接使用wordpress中的图像?

Php 如何通过本地链接使用wordpress中的图像?,php,html,wordpress,Php,Html,Wordpress,在这段代码中,我想使用保存在笔记本电脑中的内部图像。使用的代码已被复制,并且使用了外部链接。问题是更改路径后图像不会出现,所以如果我遗漏了什么,请告诉我。提前谢谢 <div class="row home-team"> <div class="col-md-3 col-sm-6 dream-team-item"> <div class="row dream-team-detail"> <div class="img-thumbnail">

在这段代码中,我想使用保存在笔记本电脑中的内部图像。使用的代码已被复制,并且使用了外部链接。问题是更改路径后图像不会出现,所以如果我遗漏了什么,请告诉我。提前谢谢

    <div class="row home-team">
<div class="col-md-3 col-sm-6 dream-team-item">
<div class="row dream-team-detail">
<div class="img-thumbnail">
<p><img class="img-responsive home_team_thumb wp-post-image" src="C:/xampp/htdocs/wordpress/wp-content/themes/dream/images/image.jpg" alt="" width="1140" height="760"></p>
<div class="overlay"></div>
</div>
<h3 class="member-name"><a href="#"> Name</a></h3>
<p>( Age)</p>
</div>
</div>

我发现路径不同,在这种情况下,我建议对图像使用相同的文件夹(主题或上传)

如果您想在两种环境(web和localhost)中都使用“主题”文件夹,您可以这样使用:

<?php
  #this line below returns http://yourwebsite/wp-content/themes
  $themes_path = get_theme_root_uri();  
?>
<p><img class="img-responsive home_team_thumb wp-post-image" src="<?=$themes_path;?>/dream/images/image.jpg" alt="" width="1140" height="760"></p>

/dream/images/image.jpg“alt=”“width=“1140”height=“760”>

现在,如果您想保留“上载”文件夹,可以执行以下操作:

<?php
  $upload_dir   = wp_upload_dir();
?>
<p><img class="img-responsive home_team_thumb wp-post-image" src="<?=$upload_dir['baseurl'];?>/sites/23/2016/10/team1-1140x760.jpg" alt="" width="1140" height="760"></p>

/sites/23/2016/10/team1-1140x760.jpg“alt=”“width=“1140”height=“760”>


使用$upload_dir['basedir']可以获得完整的url“or”

我发现路径不同,在这种情况下,我建议对图像使用相同的文件夹(主题或上传)

如果您想在两种环境(web和localhost)中都使用“主题”文件夹,您可以这样使用:

<?php
  #this line below returns http://yourwebsite/wp-content/themes
  $themes_path = get_theme_root_uri();  
?>
<p><img class="img-responsive home_team_thumb wp-post-image" src="<?=$themes_path;?>/dream/images/image.jpg" alt="" width="1140" height="760"></p>

/dream/images/image.jpg“alt=”“width=“1140”height=“760”>

现在,如果您想保留“上载”文件夹,可以执行以下操作:

<?php
  $upload_dir   = wp_upload_dir();
?>
<p><img class="img-responsive home_team_thumb wp-post-image" src="<?=$upload_dir['baseurl'];?>/sites/23/2016/10/team1-1140x760.jpg" alt="" width="1140" height="760"></p>

/sites/23/2016/10/team1-1140x760.jpg“alt=”“width=“1140”height=“760”>


使用$upload_dir['basedir']可以获得完整的url“or”

可能的重复这是正确的。您应该始终使用函数族,如
get\u theme\u root\u uri()
get\u stylesheet\u directory\u uri()
,这样可以使主题更易于移植。这是正确的。您应该始终使用函数族,如
get\u theme\u root\u uri()
get\u stylesheet\u directory\u uri()
,因为这样可以使主题更易于移植。