php - 无法在我的 wordpress 自定义主题中裁剪标题图片

标签 php css wordpress image

从今天开始我开始学习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/

相关文章:

php 发送 curl 请求并等待响应

php - Android数据到PHP到MYSQL

php - QuickBooks 在 id 周围合并字节、方括号和连字符

javascript - 以 Angular 4 更改元素 <a> 的属性

mysql - 优化 WordPress 查询

php - 如何从WordPress数据库中获取特定结果集中倒数第三个user_id?

php - 在codeigniter中检查AJAX调用是否成功

html - 如何制作栏目

css - 热门使用::-webkit-scrollbar隐藏单向横条或竖条?

css - 太多的填充/间距但不是在代码中