简体   繁体   English

调整header.php

[英]Adjust header.php

A client has asked me to switch out the site-title with a logo she's designed in the header.php. 一位客户要求我用在header.php中设计的徽标来切换网站标题。 I've been reading about child themes but don't know enough context to definitively implement the change. 我一直在阅读有关儿童主题的信息,但我所了解的上下文不足以明确实施更改。

The code is: 代码是:

<header id="masthead" class="site-header" role="banner">
    <hgroup>
        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
        <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
    </hgroup>

    <nav id="site-navigation" class="main-navigation" role="navigation">
        <button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button>
        <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
        <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
    </nav><!-- #site-navigation -->

    <?php if ( get_header_image() ) : ?>
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /></a>
    <?php endif; ?>
</header>`

I just need to replace the site-title with the logo. 我只需要用徽标替换站点标题即可。 Any guidance? 有指导吗?

I also need to import the image, would I use a FTP? 我还需要导入图像,我会使用FTP吗? Are there any restrictions on where to save the image? 保存图像的位置是否有限制?

I do not know much about wordpress. 我对wordpress不太了解。 However, this might work, 但是,这可能有效,

<header id="masthead" class="site-header" role="banner">
<hgroup>
    <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src="<?php bloginfo('template_directory'); ?>/images/imagename.png" alt="" width="xxx" height="xxx" /></a></h1>

So, basically what I did is, I replaced <?php bloginfo( 'name' ); ?> 因此,基本上我所做的是,我替换了<?php bloginfo( 'name' ); ?> <?php bloginfo( 'name' ); ?> from the third line of your code to <img src="<?php bloginfo('template_directory'); ?>/images/imagename.png" alt="" width="xxx" height="xxx" /> . <?php bloginfo( 'name' ); ?>从代码的第三行到<img src="<?php bloginfo('template_directory'); ?>/images/imagename.png" alt="" width="xxx" height="xxx" /> Please replace 'template_directory' and "xxx" by proper values. 请用正确的值替换“ template_directory”和“ xxx”。

https://wordpress.org/support/topic/images-within-wordpress-theme-files https://wordpress.org/support/topic/images-within-wordpress-theme-files

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

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