首页 文章

Header.php文件中的图像显示在Wordpress网站的主页上,但不显示在其他页面上

提问于
浏览
0

我希望在导航栏中的WordPress站点名称之前显示一个小图像 .

这是我写入header.php文件的代码,用于显示图像 .

<a class="navbar-brand" href="<?php echo home_url(); ?>">
  <img src="img/logo.png" width="25px" height="25px" style="top: -3px; position: relative;"/> 
  &nbsp; 
  <?php bloginfo('name'); ?>
</a>

我已将img文件夹及其内部的logo.png放在我的网站托管的根目录,wp-content和主题文件夹中 .

我在我的笔记本电脑上托管WordPress以使用WAMP服务器进行开发,并且在我工作时它起作用,但是当我把它放在GoDaddy上时,发生了错误 .

看起来像logo.png文件,除非在网站的主页上,这是静态主页 .

我感谢你们的任何帮助,如果需要提供更多的信息,我将很乐意帮忙 .

1 回答

  • 1

    img 文件夹(其中包含徽标)放在主题目录中(即 wp-content/themes/your-theme-name/ ) . 然后改变图像的 src 属性,如下所示:

    <img src="<?php bloginfo( 'stylesheet_directory' ); ?>/img/logo.png" width="25px" height="25px" style="top: -3px; position: relative;"/>
    

相关问题