简体   繁体   中英

Adjust header.php

A client has asked me to switch out the site-title with a logo she's designed in the 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? Are there any restrictions on where to save the image?

I do not know much about 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' ); ?> from the third line of your code to <img src="<?php bloginfo('template_directory'); ?>/images/imagename.png" alt="" width="xxx" height="xxx" /> . Please replace 'template_directory' and "xxx" by proper values.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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