我一直挖掘通过可湿性粉剂的可湿性粉剂没有运气,我有自定义标题启用,我可以上传图像,从那里我可以设置一些css来选择我是否希望它是全宽或重复,但我想添加一个选项,以使我可以选择重复或全宽的图像可能会改变,而不是总是一个长横幅。
当前使用以下参数:
// Add Theme Support for Custom Header
// =========================================================================== //
$defaults = array(
'width' => 0,
'height' => 0,
'flex-width' => true,
'flex-height' => true,
'uploads' => true,
'random-default' => false,
'header-text' => false,
'default-text-color' => '',
'wp-head' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
'default-image' => get_template_directory_uri() . '/images/header.jpg',
);
add_theme_support( 'custom-header', $defaults );发布于 2015-11-12 13:24:54
你说“重复”作为一个选项,我假设图像将被用作背景。为此,您必须使用CSS,因此没有可用于自定义标题的设置。但是,您可以进行单独的控件和设置,并将它们添加到自定义页眉部分。它看起来就像这样...
<?php
$wp_customize->add_control(
'header_background_size',
array(
'label' => __( 'Background Style', 'mytheme' ),
'section' => 'header_image',
'settings' => 'header_background_size',
'type' => 'select',
'choices' => array(
'cover' => 'Cover',
'contain' => 'Contain',
'auto' => 'Normal',
),
)
);
$wp_customize->add_setting( 'header_background_size' , array(
'default' => 'cover',
'transport' => 'refresh',
) );
$wp_customize->add_control(
'header_background_repeat',
array(
'label' => __( 'Background Style', 'mytheme' ),
'section' => 'header_image',
'settings' => 'header_background_repeat',
'type' => 'select',
'choices' => array(
'repeat' => 'Repeat',
'repeat-x' => 'Repeat X',
'repeat-y' => 'Repeat Y',
'no-repeat' => 'No Repeat',
),
)
);
$wp_customize->add_setting( 'header_background_repeat' , array(
'default' => 'repeat',
'transport' => 'refresh',
) );
?>你的头文件div看起来像这样...
<div class="header"
<?php if ( get_custom_header() ) : ?>
style="
background-image: url(<?php header_image(); ?>);
background-size:<?php echo get_theme_mod('header_background_size', 'cover'); ?>;
background-repeat:<?php echo get_theme_mod('header_background_repeat', 'repeat'); ?>;
"
<? endif; ?>>https://stackoverflow.com/questions/32482701
复制相似问题