add_custom_image_header()自定义头部图片

目录

描述

译文

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

回调参数$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.

add_custom_image_header() 描述

用法

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

add_custom_image_header() 用法

参数

$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

add_custom_image_header() 参数

返回值

(void) 

This function does not return a value.

add_custom_image_header() 返回值

示例

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.

add_custom_image_header() 示例

注意

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

add_custom_image_header() 注意

历史

add_custom_image_header() 历史

源文件

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

add_custom_image_header() 源文件

相关