WordPress二十三个孩子主题更改标题横幅尺寸

时间:2017-04-19 16:16:16

标签: php html css wordpress child-theming

我希望有人可以帮我解决以下问题。

我使用以WordPress二十三主题为基础的儿童主题创建网站。 在这里,我被要求添加一个大小为1100x328px的标题横幅。问题是Twenty Thirteen Theme的固定大小为1600x230px,因此我需要更改标题横幅的大小。

现在我在&custom-header.php'中找到了以下代码:位于Twenty Thirteen文件夹内的' inc-文件夹中。

function twentythirteen_custom_header_setup() {
  $args = array(
    // Text color and image (empty to use none).
    'default-text-color'     => '220e10',
    'default-image'          => '%s/images/headers/circle.png',

    // Set height and width, with a maximum value for the width.
    'height'                 => 230,
    'width'                  => 1600,

    // Callbacks for styling the header and the admin preview.
    'wp-head-callback'       => 'twentythirteen_header_style',
    'admin-head-callback'    => 'twentythirteen_admin_header_style',
    'admin-preview-callback' => 'twentythirteen_admin_header_image',
  );

  add_theme_support( 'custom-header', $args );
    .
    .
    .
}

进一步向下:

.site-header {
    background: url(<?php header_image(); ?>) no-repeat scroll top;
    background-size: 1600px auto;
}

如果我更改了值&#39; height &#39;和&#39; 宽度&#39;在第一部分中,更改&#39; 背景大小&#39;该课程&#39; .site-header &#39;再往下,最后改变班级的 min-height &#39; .site-header .home-link &#39;在&#39; style.css &#39;中,它的效果非常好。 横幅显示为我想要的。

但是现在,因为我使用了儿童主题,如果在那里进行这些更改会更好,而不是在父主题中。但我还没弄明白该怎么做。

有没有办法在子主题中更改这些值(例如在functions.php中),还是只能在父主题中更改它?

问候shinigami

1 个答案:

答案 0 :(得分:0)

首先,您无法更改 functions.php 中的require get_template_directory() . '/inc/custom-header.php';,因为它未在函数内声明。

我的建议是使用css而不是处理Wordpress核心功能。你可以使用

.site-header {
    background-size: 1100px auto !important;
}

但是,如果您只想玩twentythirteen_custom_header_setup内的内容,可以在子主题 functions.php 中更改此内容。以下是如何做到这一点:

$args = array(
'height'                 => 328,
'width'                  => 1100
);
add_theme_support( 'custom-header', $args );

甚至你可以像这样更改该函数内的所有内容:

$args = array(
// Text color and image (empty to use none).
'default-text-color'     => '220e10',
'default-image'          => '%s/images/headers/circle.png',

// Set height and width, with a maximum value for the width.
'height'                 => 328,
'width'                  => 1100,

// Callbacks for styling the header and the admin preview.
'wp-head-callback'       => 'twentythirteen_header_style',
'admin-head-callback'    => 'twentythirteen_admin_header_style',
'admin-preview-callback' => 'twentythirteen_admin_header_image',
);
add_theme_support( 'custom-header', $args );

希望这有帮助。

相关问题