在MAMP上工作时如何将图像添加到wordpress主题?

我是MAMP的新手, 正在开发我设计的主题。但是我似乎无法获得要渲染的图像。我正在使用从starkerstheme.com获得的清晰主题, 将图像直接添加到我使用的代码中时:

<img src="<?= $theme ?>/images/logo.png"/>

但是图像没有显示出来, 我也试图将其添加到媒体库中, 但仍无法渲染。


#1


这对我有用:

<img src="<?php echo get_bloginfo('template_url') ?>/images/logo.png"/>

有关更多信息, 请参见get bloginfo()函数。


#2


你可以使用以下代码添加图像。这对我有用:

<img src="<?php echo get_template_directory_uri(); ?>/images/filename.png">

#3


只需转到仪表板, 然后在媒体部分上传图片, 然后选择它, 你将看到图像选项..然后将其复制为网址<img src =” your / copied / url” />这个aslo在本地主机上对我有用


#4


<?php echo get_template_directory_uri(); ?> 

按照建议获取PARENT主题, 这很好, 但是如果你已经开发了子主题(如WordPress人员所推荐), 则需要:

<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/Logo.png">

#5


你可能需要执行完整的<img src =” <?php echo $ theme;?> / images / logo.png” />

更新我没有足够仔细地阅读你的问题。如果你将媒体库用于图像, 则需要指定图像的实际路径。你可以在媒体库中找到答案, 但可能是site_url / wp-content / uploads / 2012/01 / filename.jpg

简而言之, 如果你将其上传到媒体中, 则实际上不会出现在你的主题中。


#6


<?php bloginfo('template_directory'); ?>/

用于图像中的内部根文件夹以放置在wordpress的主题上。要显示图像, 需要使用正斜杠


#7


在<?之后删除=。

<img src =” <?$ theme?> / images / logo.png” />

实际上, 我可能会做这样的事情:

<img src = <?php $ theme?> ” /images/logo.png” />

来源:

https://www.srcmini02.com/65243.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37322.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?