douqiu0351 2014-11-14 09:05
浏览 11
已采纳

我如何获得wp自定义标题图像的条件?

I m developing a wordpress theme for wordpress theme directory. In this theme, I have set a custom header image by this bellow at functions.php

$defaults = array(
 'width'         => 1600,
 'height'        => 400,
 'flex-height'    => false,
 'flex-width'    => false,
 'default-image' => get_template_directory_uri() . '/images/lemon.jpg',
 'uploads'       => true,
 'default-text-color' => '95b849',
 'header-text' => true,
);    
add_theme_support( 'custom-header',$defaults);

and I show this header image like bellow:

<div class="header_top_image" style="background-image: url(<?php header_image(); ?>); background-color: #<?php echo get_header_textcolor();?>;">
 <h1 class="header_top_title">
    <a style="color: #<?php echo get_header_textcolor();?>;" href="<?php echo esc_url( home_url( '/' ) ); ?>">
     <?php bloginfo('name'); ?>
    </a>
 </h1>
</div>

In this situation, I want: if not set Custom Header image, This "header_top_image" class's div tag totally don't show.

How I can do that. Actually I thought, there is a function: is_custome_header() , even I search at codex. But not found any function like this which provide if condition. Any body can help me? I need very much this solution. Advance thanks

  • 写回答

1条回答 默认 最新

  • douju1953 2014-11-14 11:10
    关注

    Actually now I got solution. it will:

    <?php
    if(get_header_image()){ ?>
    <div>Desired div/elements here</div>
    <?php } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?