[英]Adjust header.php
一位客戶要求我用在header.php中設計的徽標來切換網站標題。 我一直在閱讀有關兒童主題的信息,但我所了解的上下文不足以明確實施更改。
代碼是:
<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>`
我只需要用徽標替換站點標題即可。 有指導嗎?
我還需要導入圖像,我會使用FTP嗎? 保存圖像的位置是否有限制?
我對wordpress不太了解。 但是,這可能有效,
<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>
因此,基本上我所做的是,我替換了<?php bloginfo( 'name' ); ?>
<?php bloginfo( 'name' ); ?>
從代碼的第三行到<img src="<?php bloginfo('template_directory'); ?>/images/imagename.png" alt="" width="xxx" height="xxx" />
。 請用正確的值替換“ template_directory”和“ xxx”。
https://wordpress.org/support/topic/images-within-wordpress-theme-files
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.