WordPress函数文档add_custom_image_header()

自定义头部图片 描述 译文 为图片页面显示添加回调。 回调参数$header_callback需要为’wp_h…

自定义头部图片

描述

译文

为图片页面显示添加回调。

回调参数$header_callback需要为’wp_head’动作显示内容。将回调参数 $admin_header_callback添加到Custom_Image_Header类中,将添加后的结果加入’admin_menu’动作

原文

Add callbacks for image header display.

The parameter $header_callback callback will be required to display the content for the ‘wp_head‘ action. The parameter $admin_header_callback callback will be added to Custom_Image_Header class and that will be added to the ‘admin_menu‘ action.

用法

<?php add_custom_image_header$header_callback$admin_header_callback$admin_image_div_callback ?>

参数

$header_callback

(callback) (必填) Call on ‘wp_head‘ action.

默认值: None

$admin_header_callback

(callback) (必填) Call on custom header administration screen.

默认值: None

$admin_image_div_callback

(callback) (必填) Output a custom header image div on the custom header administration screen. Optional.

默认值: None

返回值

(void) 

This function does not return a value.

示例

Edit the file functions.php inside your theme and add the following code.

Four constants must be defined in order for the custom image header to work:

If you don’t want to allow changing the header text color, add:

Then change the first definition to:

If you intend to create child themes use:

Otherwise, you’ll pick up the header image for the parent theme rather than the child.

Next you need to write two functions. One will be included in the site header. The second will be included in the admin header. Both of these functions are required. The smallest possible amount of code would be something like this, although you can do anything you need.

Finish with calling the add_custom_image_header function with the two earlier function names as parameters:

Taking this last step will make the Custom Header item appear in the Appearance menu. WordPress takes care of everything else.

注意

  • 使用到: Custom_Image_Header. Sets up for $admin_header_callback for administration panel display.

历史

  • Deprecated: 3.4.0
  • 添加于 版本: 2.1.0

源文件

add_custom_image_header() 函数的代码位于 wp-includes/theme.php.

相关

Custom Headers:
add_custom_image_header(),
remove_custom_image_header(),
register_default_headers(),
unregister_default_headers()

  • 原文:http://codex.wordpress.org/Function_Reference/add_custom_image_header
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT