get_header_image()
Retrieve header image for custom header.
描述
返回值
(string|false)
源代码
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
-
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.
Example
<img src="<?php echo esc_url( get_header_image() ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'title' ) ) ); ?>" />
你可能对这些文章感兴趣:
- wordpress函数get_the_posts_navigation()用法示例
- wordpress函数get_the_title()用法示例
- wordpress函数get_the_taxonomies()用法示例
- wordpress函数get_the_terms()用法示例
- wordpress函数get_the_tags()用法示例
- wordpress函数get_the_permalink()用法示例
- wordpress函数get_the_password_form()用法示例
- wordpress函数get_the_posts_pagination()用法示例
- wordpress函数get_the_modified_date()用法示例
- wordpress函数get_the_modified_time()用法示例
- wordpress函数get_the_modified_author()用法示例
- wordpress函数get_the_guid()用法示例
- wordpress函数get_the_ID()用法示例
- wordpress函数get_the_excerpt()用法示例
如有疑问,请前往问答中心反馈!
反馈