Function Signature:
header_image
Function Description:
Displays header image URL.
Function Examples:
⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Display the default header image
if (function_exists('the_custom_header_markup')) {
the_custom_header_markup();
}
// Example 2: Set a custom header image for a specific page
if (is_page('about')) {
add_filter('header_image', 'custom_header_image');
function custom_header_image() {
return 'http://example.com/wp-content/uploads/2021/01/about-header.jpg';
}
}
// Example 3: Display a random header image from a specified list
$random_images = array(
'http://example.com/wp-content/uploads/2021/01/header1.jpg',
'http://example.com/wp-content/uploads/2021/01/header2.jpg',
'http://example.com/wp-content/uploads/2021/01/header3.jpg'
);
add_filter('header_image', 'random_header_image');
function random_header_image() {
global $random_images;
return $random_images[array_rand($random_images)];
}