php - WordPress 20 13 子主题更改标题横幅大小

标签 php html css wordpress child-theming

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

我正在使用以 WordPress 20 13 主题为基础的子主题创建一个网站。 在这里,我被要求添加一个大小为 1100x328 像素的标题横幅。问题是 2013 主题的固定大小为 1600x230px,因此我需要以某种方式更改标题横幅的大小。

现在我在“custom-header.php”中找到了以下代码,该文件位于“二十三”文件夹内的“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;
}

如果我在第一部分中更改值“height”和“width”,则更改“background-size” class '.site-header' 再往下,最后改变class '.site-header .home-linkmin-height ' 在 'style.css' 中,它工作得很好。 横幅显示如我所愿。

但是现在,由于我使用的是子主题,所以如果在其中进行这些更改会更好,而不是在父主题中进行。但我还没有弄清楚该怎么做。

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

问候死神

最佳答案

首先,您不能更改require get_template_directory() 。 '/inc/custom-header.php';functions.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 );

希望这对您有所帮助。

关于php - WordPress 20 13 子主题更改标题横幅大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43501027/

相关文章:

php - 时间戳 - 天之间的间隔并不总是 86400 秒 - 为什么?

javascript - 可搜索的下拉列表

javascript - 使用 css/jquery 作为链接的背景图片

javascript - 如果悬停在其他链接上,需要停用点击功能

php - mysqli::mysqli(): (HY000/2002): 无法通过套接字 'MySQL' 连接到本地 MySQL 服务器 (2)

php - 没有可用于包的版本

javascript - 将 JavaScript 代码合并到一个函数中时,代码将无法工作

css - 谷歌浏览器上的边界半径中断

javascript - 如何创建单选框文本库

java - 如何更改 GWT 的小部件 CSS 值?