WordPress Theme production in the custom header of the relevant PHP function parsing, WordPress production
Header_image ()
The Header_image () function is a standard interface function for WordPress custom top image, which automatically determines the background settings and returns the user-defined top image address in the form of a string. This paper mainly deals with the explanation and use of the function.
"Display header image path." That is, displays the top image address.
Use
Copy the Code code as follows:
"Width=" <?php echo $header _image_width,?> "height=" <?php echo $header _image_height;?> "alt=" "/>
function declaration Source Code
function Header_textcolor () {echo Get_header_textcolor ();} 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 (); if (Is_ssl ()) $url = Str_replace (' http://', ' https://', $url); else $url = str_replace (' https://', ' http://', $url); Return Esc_url_raw ($url);}
Get_custom_header Custom Top
Get_custom_header function is a new gift from WordPress 3.4, the function is to better integrate and encapsulate the use of the top, this article mainly on the function of Get_custom_header, and how the WordPress The 3.4 version of the theme integrates the top features.
Please note that as the article toss your theme, make sure that your WordPress has been upgraded to version 3.4.
Get_custom_header meaning of the explanation
Custom top most of the topics currently used are only two features 1. Customize top image 2. Custom Top Style
Specific effects you can take a look at the default theme twenty eleven, or my other blog my Heart
This function is a built-in function that appears after WP 3.4 and is used primarily to return the parameters of the top of the user's settings as objects (object).
Just say such a fart, perhaps you do not understand, if you want to understand, please look down.
Note that this function is fundamentally different from get_header ().
Function Usage Instance
The following example is from the default theme twenty eleven in the header.php file
PHP Code:
Determine if the function exists so that compatibility with the old version if (function_exists (' Get_custom_header ')) {//get_custom_header ()->width calls the Width property $header_ Image_width = Get_custom_header ()->width;//get_custom_header ()->height call with the height property $header_image_height = Get _custom_header ()->height;} else {//compatible with older versions of code $header_image_width = header_image_width; $header _image_height = Header_image_height;}
Comprehensive use of the detailed
The following mainly cite official documents explaining the custom top
Open Theme Custom Top support Add_theme_support (' Custom-header '); $headarg = Array (//sets the package to ' default-image ' = ' + ' , ' random-default ' = false, ' width ' = 0, ' Height ' = + 0, ' flex-height ' and false, ' flex-width ' = False, ' default-text-color ' = ', ' Header-text ' = ' = true, ' uploads ' = ' = true, ' wp-head-callback ' = ', ' admin-head-callback ' = > ', ' admin-preview-callback ' = ', ', ';//Add the settings in the array to the top of the custom Add_theme_support (' Custom-header ', $headarg);
Customizing the top image
Open Theme Custom Top support Add_theme_support (' Custom-header '); $headarg = Array (//sets the package to ' default-image ' = ' + ' , ' random-default ' = false, ' width ' = 0, ' Height ' = + 0, ' flex-height ' and false, ' flex-width ' = False, ' default-text-color ' = ', ' Header-text ' = ' = true, ' uploads ' = ' = true, ' wp-head-callback ' = ', ' admin-head-callback ' = > ', ' admin-preview-callback ' = ', ', ';//Add the settings in the array to the top of the custom Add_theme_support (' Custom-header ', $headarg);
Adaptive Top Image settings
$args = Array (' flex-width ' = true,//Adaptive height ' width ' = 980, ' flex-width ' = true,//Adaptive width ' Height ' = ', ' default-image ' = Get_template_directory_uri (). '/images/header.jpg ',); Add_theme_support (' Custom-header ', $args);
Customize the call to the top image
" height=" <?php Echo get_custom_header ()->height;?> " width=" <?php Echo get_custom_header ()- >width;?> " alt=" "/>
Articles you may be interested in:
- Introduction of template file for WordPress theme making
- WordPress Theme Authoring in Get header template and bottom template
- WordPress Theme Add Article List page number navigation PHP code instance
- WordPress enables themes to support gadgets and add plug-in enable functions
- PHP script to implement WordPress theme side bar switching function
- Write PHP script to make WordPress Theme Support Widget Sidebar
- The concrete implementation steps based on WordPress theme making
- WordPress Theme Support custom menu and modify CSS style implementation method
http://www.bkjia.com/PHPjc/1089941.html www.bkjia.com true http://www.bkjia.com/PHPjc/1089941.html techarticle WordPress Theme of the custom header of the relevant PHP function parsing, WordPress production header_image () Header_image () function is the WordPress custom top image of the standard interface function, the letter ...