我正在使用Foundation press并尝试用公司徽标替换网站标题。但是,如果没有上传徽标,则网站标题应保持不变。
在functions.php中我有:
function themename_custom_logo_setup() {
$defaults = array(
'height' => 100,
'width' => 100,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
);
add_theme_support( 'custom-logo', $defaults );
}
add_action( 'after_setup_theme', 'themename_custom_logo_setup' );
然后在我的header.php中,我有以下内容:
<div class="site-title-bar title-bar" <?php foundationpress_title_bar_responsive_toggle() ?>>
<div class="title-bar-left">
<button class="menu-icon" type="button" data-toggle="<?php foundationpress_mobile_menu_id(); ?>"></button>
<div class="site-branding">
<?php
$logo_id = get_theme_mod( 'custom_logo' );
$logo_image = wp_get_attachment_image_src( $logo_id, 'full' );
if ( ! empty( $logo_image ) ) :
?>
<span class="site-logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><img src="<?php echo esc_url( $logo_image[0] ); ?>" alt="<?php bloginfo( 'name' ); ?>"/></a></span>
<?php else : ?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php endif; ?>
</div><!-- site-branding -->
</div><!-- title-bar-left -->
</div><!-- site-title-bar title-bar -->
插入徽标的选项会显示在自定义程序中。但是,徽标没有被拉入网站?