^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_header_image()用法示例

get_header_image()

Retrieve header image for custom header.


描述


返回值

(string|false)

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


源代码

File: wp-includes/theme.php

function get_header_image() {
	$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );

	if ( 'remove-header' == $url )
		return false;

	if ( is_random_header_image() )
		$url = get_random_header_image();

	return esc_url_raw( set_url_scheme( $url ) );
}

更新日志

Version 描述
2.1.0 Introduced.

相关函数

Uses

  • wp-includes/theme.php:
    get_theme_support()
  • wp-includes/theme.php:
    is_random_header_image()
  • wp-includes/theme.php:
    get_random_header_image()
  • wp-includes/theme.php:
    get_theme_mod()
  • wp-includes/formatting.php:
    esc_url_raw()
  • wp-includes/link-template.php:
    set_url_scheme()
  • Show 1 more use


Used By

  • wp-includes/theme.php:
    get_header_video_settings()
  • wp-includes/theme.php:
    get_header_image_tag()
  • wp-includes/theme.php:
    has_header_image()
  • wp-admin/includes/template.php:
    _media_states()
  • wp-admin/custom-header.php:
    Custom_Image_Header::step_1()
  • wp-includes/theme.php:
    _delete_attachment_theme_mod()
  • wp-includes/theme.php:
    header_image()
  • Show 2 more used by
    Hide more used by


  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 3You must log in to vote on the helpfulness of this note

    Contributed by jessedyck

    Before using this, check out get_header_image_tag() first. That’s a new function in 4.4 that’ll return an tag including the srcset attributes for responsive images.

    get_header_image_tag()

  2. Example

    
    <img src="<?php echo esc_url( get_header_image() ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'title' ) ) ); ?>" />
    

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈