简体   繁体   English

header.php中的Wordpress徽标图像

[英]Wordpress logo image in header.php

I'm trying to create a custom theme in Wordpress, and currently I'm working on my header.php file. 我正在尝试在Wordpress中创建自定义主题,目前正在处理header.php文件。 However, I'm unable to display my logo image. 但是,我无法显示我的徽标图像。 Here's the code for the same: 这是相同的代码:

<body>

        <div class = "container">
            <div class = "five columns">
                <a href = "<?php echo get_option('home'); ?>"><img src = "<?php bloginfo('template_url'); ?>/img/sem.jpg" title = "<?php bloginfo('title'); ?>"></a>
            </div>
        </div>

    </body>

The sem.jpg image is stored inside the img folder inside my root project directory. sem.jpg图像存储在我的根项目目录下的img文件夹内。 However, the logo doesn't seem to be displayed on my webpage. 但是,徽标似乎没有显示在我的网页上。 I have also tried using images of other formats, but none of them seems to work. 我也尝试过使用其他格式的图像,但是它们似乎都不起作用。 I have also called the get_header() function inside my index.php . 我在index.php也调用了get_header()函数。

What seems to be wrong in my code? 我的代码中似乎有什么问题?

The reason seems a permissions problem. 原因似乎是权限问题。 You can set permission 777 to the logo image via command line, typyng: 您可以通过命令行typyng将777权限设置为徽标图像:

   chmod 777 /path_to_your_file

or set using right click on the logo file, and change properties. 或通过右键单击徽标文件进行设置,然后更改属性。

You can't view your image because you have got set wrong permissions on your image. 您无法查看图片,因为您对图片设置了错误的权限。 Open your FTP client, connect to your site and find your image, right click it and chosse Change file permissions and change them to 644. 打开您的FTP客户端,连接到您的站点并找到您的图像,右键单击它并选择“更改文件权限”并将其更改为644。

File permissions should look like this: 文件权限应如下所示:

http://s12.postimg.org/rxb25ziy5/Untitled.png http://s12.postimg.org/rxb25ziy5/Untitled.png

Try This. 尝试这个。

<body <?php body_class(); ?>>

        <div class = "container">
            <div class = "five columns">

    <img src="<?php echo get_template_directory_uri(); ?>/img/sem.jpg"  alt="<?php bloginfo('title'); ?" />
 </div>
        </div>

    </body>

Enjoy..!! 请享用..!!

user this wordpress plugin it will help yo upload logo using wordpress admin and you can change any time with edit header.php file. 用户这个WordPress的插件 ,它将帮助您使用WordPress的管理员上传徽标,您可以随时通过编辑header.php文件进行更改。 Use below function to print logo 使用以下功能打印徽标

echo theme_logo(); 回声theme_logo();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM