从今天开始我开始学习wordpress的自定义主题开发,目前我遇到了一个问题,当我尝试为标题裁剪图像时显示错误。下面是示例代码。
(1. 我已经为标题图像 functions.php 设置了钩子(Hook)
add_theme_support('custom-header');
(2.在header.php里面设置图片
<img class="myhead" src="<?php header_image(); ?>" height="<?php get_custom_header()->height ?>"
width="<?php get_custom_header()->width ?>" alt="">
(3.测试图片是否显示在header内,图片以实际尺寸显示。
如何在自定义中自定义标题图片?我很想听听你的意见。
最佳答案
flex-width
& flex-height
是自行调整的,
$args = array(
'flex-width' => true,
'width' => 980,
'flex-height' => true,
'height' => 200,
'default-image' => get_template_directory_uri() . '/images/header.jpg',
);
add_theme_support( 'custom-header', $args );
更新你的 header.php
<img alt="" src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" />
关于php - 无法在我的 wordpress 自定义主题中裁剪标题图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35112343/